moved StreamingDestination inside ClientDestination

This commit is contained in:
orignal 2014-10-22 11:46:54 -04:00
parent ab843b6552
commit 4d97b0e206
12 changed files with 187 additions and 189 deletions

View file

@ -18,6 +18,10 @@
namespace i2p
{
namespace client
{
class ClientDestination;
}
namespace stream
{
const uint16_t PACKET_FLAG_SYNCHRONIZE = 0x0001;
@ -141,6 +145,43 @@ namespace stream
size_t m_NumSentBytes, m_NumReceivedBytes;
};
class StreamingDestination
{
public:
StreamingDestination (i2p::client::ClientDestination& owner): m_Owner (owner) {};
~StreamingDestination () {};
void Start ();
void Stop ();
Stream * CreateNewOutgoingStream (const i2p::data::LeaseSet& remote);
void DeleteStream (Stream * stream);
void SetAcceptor (const std::function<void (Stream *)>& acceptor) { m_Acceptor = acceptor; };
void ResetAcceptor () { m_Acceptor = nullptr; };
bool IsAcceptorSet () const { return m_Acceptor != nullptr; };
// ClientDestination
i2p::client::ClientDestination& GetOwner () { return m_Owner; };
void HandleNextPacket (Packet * packet);
private:
Stream * CreateNewIncomingStream ();
private:
i2p::client::ClientDestination& m_Owner;
std::mutex m_StreamsMutex;
std::map<uint32_t, Stream *> m_Streams;
std::function<void (Stream *)> m_Acceptor;
public:
// for HTTP only
const decltype(m_Streams)& GetStreams () const { return m_Streams; };
};
//-------------------------------------------------
template<typename Buffer, typename ReceiveHandler>