delete stream by id for HTTP interface

This commit is contained in:
orignal 2020-03-04 15:54:09 -05:00
parent 8dae044600
commit 1e9a53da3f
4 changed files with 21 additions and 0 deletions

View File

@ -1191,6 +1191,16 @@ namespace client
} }
} }
bool ClientDestination::DeleteStream (uint32_t recvStreamID)
{
if (m_StreamingDestination->DeleteStream (recvStreamID))
return true;
for (auto it: m_StreamingDestinationsByPorts)
if (it.second->DeleteStream (recvStreamID))
return true;
return false;
}
RunnableClientDestination::RunnableClientDestination (const i2p::data::PrivateKeys& keys, bool isPublic, const std::map<std::string, std::string> * params): RunnableClientDestination::RunnableClientDestination (const i2p::data::PrivateKeys& keys, bool isPublic, const std::map<std::string, std::string> * params):
RunnableService ("Destination"), RunnableService ("Destination"),
ClientDestination (GetIOService (), keys, isPublic, params) ClientDestination (GetIOService (), keys, isPublic, params)

View File

@ -281,6 +281,7 @@ namespace client
// for HTTP only // for HTTP only
std::vector<std::shared_ptr<const i2p::stream::Stream> > GetAllStreams () const; std::vector<std::shared_ptr<const i2p::stream::Stream> > GetAllStreams () const;
bool DeleteStream (uint32_t recvStreamID);
}; };
class RunnableClientDestination: private i2p::util::RunnableService, public ClientDestination class RunnableClientDestination: private i2p::util::RunnableService, public ClientDestination

View File

@ -1128,6 +1128,15 @@ namespace stream
} }
} }
bool StreamingDestination::DeleteStream (uint32_t recvStreamID)
{
auto it = m_Streams.find (recvStreamID);
if (it == m_Streams.end ())
return false;
DeleteStream (it->second);
return true;
}
void StreamingDestination::SetAcceptor (const Acceptor& acceptor) void StreamingDestination::SetAcceptor (const Acceptor& acceptor)
{ {
m_Acceptor = acceptor; // we must set it immediately for IsAcceptorSet m_Acceptor = acceptor; // we must set it immediately for IsAcceptorSet

View File

@ -250,6 +250,7 @@ namespace stream
std::shared_ptr<Stream> CreateNewOutgoingStream (std::shared_ptr<const i2p::data::LeaseSet> remote, int port = 0); std::shared_ptr<Stream> CreateNewOutgoingStream (std::shared_ptr<const i2p::data::LeaseSet> remote, int port = 0);
void DeleteStream (std::shared_ptr<Stream> stream); void DeleteStream (std::shared_ptr<Stream> stream);
bool DeleteStream (uint32_t recvStreamID);
void SetAcceptor (const Acceptor& acceptor); void SetAcceptor (const Acceptor& acceptor);
void ResetAcceptor (); void ResetAcceptor ();
bool IsAcceptorSet () const { return m_Acceptor != nullptr; }; bool IsAcceptorSet () const { return m_Acceptor != nullptr; };