Browse Source

use shared ClientDestination

pull/503/head
orignal 9 years ago
parent
commit
c7173d5e1c
  1. 2
      Datagram.cpp
  2. 6
      Datagram.h
  3. 8
      Destination.cpp
  4. 2
      Destination.h
  5. 2
      Streaming.cpp
  6. 8
      Streaming.h

2
Datagram.cpp

@ -11,7 +11,7 @@ namespace i2p @@ -11,7 +11,7 @@ namespace i2p
{
namespace datagram
{
DatagramDestination::DatagramDestination (std::shared_ptr<i2p::client::LeaseSetDestination> owner):
DatagramDestination::DatagramDestination (std::shared_ptr<i2p::client::ClientDestination> owner):
m_Owner (owner), m_Receiver (nullptr)
{
}

6
Datagram.h

@ -14,7 +14,7 @@ namespace i2p @@ -14,7 +14,7 @@ namespace i2p
{
namespace client
{
class LeaseSetDestination;
class ClientDestination;
}
namespace datagram
{
@ -25,7 +25,7 @@ namespace datagram @@ -25,7 +25,7 @@ namespace datagram
public:
DatagramDestination (std::shared_ptr<i2p::client::LeaseSetDestination> owner);
DatagramDestination (std::shared_ptr<i2p::client::ClientDestination> owner);
~DatagramDestination ();
void SendDatagramTo (const uint8_t * payload, size_t len, const i2p::data::IdentHash& ident, uint16_t fromPort = 0, uint16_t toPort = 0);
@ -47,7 +47,7 @@ namespace datagram @@ -47,7 +47,7 @@ namespace datagram
private:
std::shared_ptr<i2p::client::LeaseSetDestination> m_Owner;
std::shared_ptr<i2p::client::ClientDestination> m_Owner;
Receiver m_Receiver; // default
std::map<uint16_t, Receiver> m_ReceiversByPorts;

8
Destination.cpp

@ -662,7 +662,7 @@ namespace client @@ -662,7 +662,7 @@ namespace client
{
if (LeaseSetDestination::Start ())
{
m_StreamingDestination = std::make_shared<i2p::stream::StreamingDestination> (shared_from_this ()); // TODO:
m_StreamingDestination = std::make_shared<i2p::stream::StreamingDestination> (GetSharedFromThis ()); // TODO:
m_StreamingDestination->Start ();
for (auto it: m_StreamingDestinationsByPorts)
it.second->Start ();
@ -735,7 +735,7 @@ namespace client @@ -735,7 +735,7 @@ namespace client
streamRequestComplete(CreateStream (leaseSet, port));
else
{
auto s = std::static_pointer_cast<ClientDestination>(shared_from_this ());
auto s = GetSharedFromThis ();
RequestDestination (dest,
[s, streamRequestComplete, port](std::shared_ptr<i2p::data::LeaseSet> ls)
{
@ -788,7 +788,7 @@ namespace client @@ -788,7 +788,7 @@ namespace client
std::shared_ptr<i2p::stream::StreamingDestination> ClientDestination::CreateStreamingDestination (int port, bool gzip)
{
auto dest = std::make_shared<i2p::stream::StreamingDestination> (shared_from_this (), port, gzip);
auto dest = std::make_shared<i2p::stream::StreamingDestination> (GetSharedFromThis (), port, gzip);
if (port)
m_StreamingDestinationsByPorts[port] = dest;
else // update default
@ -799,7 +799,7 @@ namespace client @@ -799,7 +799,7 @@ namespace client
i2p::datagram::DatagramDestination * ClientDestination::CreateDatagramDestination ()
{
if (!m_DatagramDestination)
m_DatagramDestination = new i2p::datagram::DatagramDestination (shared_from_this ());
m_DatagramDestination = new i2p::datagram::DatagramDestination (GetSharedFromThis ());
return m_DatagramDestination;
}

2
Destination.h

@ -174,6 +174,8 @@ namespace client @@ -174,6 +174,8 @@ namespace client
private:
void PersistTemporaryKeys ();
std::shared_ptr<ClientDestination> GetSharedFromThis ()
{ return std::static_pointer_cast<ClientDestination>(shared_from_this ()); }
private:

2
Streaming.cpp

@ -780,7 +780,7 @@ namespace stream @@ -780,7 +780,7 @@ namespace stream
m_CurrentRemoteLease = nullptr;
}
StreamingDestination::StreamingDestination (std::shared_ptr<i2p::client::LeaseSetDestination> owner, uint16_t localPort, bool gzip):
StreamingDestination::StreamingDestination (std::shared_ptr<i2p::client::ClientDestination> owner, uint16_t localPort, bool gzip):
m_Owner (owner), m_LocalPort (localPort), m_Gzip (gzip),
m_PendingIncomingTimer (m_Owner->GetService ())
{

8
Streaming.h

@ -23,7 +23,7 @@ namespace i2p @@ -23,7 +23,7 @@ namespace i2p
{
namespace client
{
class LeaseSetDestination;
class ClientDestination;
}
namespace stream
{
@ -193,7 +193,7 @@ namespace stream @@ -193,7 +193,7 @@ namespace stream
typedef std::function<void (std::shared_ptr<Stream>)> Acceptor;
StreamingDestination (std::shared_ptr<i2p::client::LeaseSetDestination> owner, uint16_t localPort = 0, bool gzip = true);
StreamingDestination (std::shared_ptr<i2p::client::ClientDestination> owner, uint16_t localPort = 0, bool gzip = true);
~StreamingDestination ();
void Start ();
@ -204,7 +204,7 @@ namespace stream @@ -204,7 +204,7 @@ namespace stream
void SetAcceptor (const Acceptor& acceptor);
void ResetAcceptor ();
bool IsAcceptorSet () const { return m_Acceptor != nullptr; };
std::shared_ptr<i2p::client::LeaseSetDestination> GetOwner () const { return m_Owner; };
std::shared_ptr<i2p::client::ClientDestination> GetOwner () const { return m_Owner; };
uint16_t GetLocalPort () const { return m_LocalPort; };
void HandleDataMessagePayload (const uint8_t * buf, size_t len);
@ -218,7 +218,7 @@ namespace stream @@ -218,7 +218,7 @@ namespace stream
private:
std::shared_ptr<i2p::client::LeaseSetDestination> m_Owner;
std::shared_ptr<i2p::client::ClientDestination> m_Owner;
uint16_t m_LocalPort;
bool m_Gzip; // gzip compression of data messages
std::mutex m_StreamsMutex;

Loading…
Cancel
Save