MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / SendMessagesTo

Method SendMessagesTo

libi2pd/TunnelBase.cpp:17–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15namespace tunnel
16{
17 void TunnelTransportSender::SendMessagesTo (const i2p::data::IdentHash& to,
18 std::list<std::shared_ptr<I2NPMessage> >&& msgs)
19 {
20 if (msgs.empty ()) return;
21 auto currentTransport = m_CurrentTransport.lock ();
22 if (!currentTransport)
23 {
24 // try to obtain transport from pending request or send thought transport is not complete
25 if (m_PendingTransport.valid ()) // pending request?
26 {
27 if (m_PendingTransport.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
28 {
29 // pending request complete
30 currentTransport = m_PendingTransport.get (); // take transports used in pending request
31 if (currentTransport)
32 {
33 if (currentTransport->IsEstablished ())
34 m_CurrentTransport = currentTransport;
35 else
36 currentTransport = nullptr;
37 }
38 }
39 else // still pending
40 {
41 // send through transports, but don't update pending transport
42 i2p::transport::transports.SendMessages (to, std::move (msgs));
43 return;
44 }
45 }
46 }
47 if (currentTransport) // session is good
48 // send to session directly
49 currentTransport->SendI2NPMessages (msgs);
50 else // no session yet
51 // send through transports
52 m_PendingTransport = i2p::transport::transports.SendMessages (to, std::move (msgs));
53
54 }
55
56 void TunnelTransportSender::SendMessagesTo (const i2p::data::IdentHash& to,
57 std::list<std::shared_ptr<I2NPMessage> >& msgs)

Callers 3

SendBufferMethod · 0.80
FlushTunnelDataMsgsMethod · 0.80
FlushI2NPMsgsMethod · 0.80

Calls 3

SendMessagesMethod · 0.80
IsEstablishedMethod · 0.45
SendI2NPMessagesMethod · 0.45

Tested by

no test coverage detected