Browse Source

delete stream by id for HTTP interface

pull/1499/head
orignal 5 years ago
parent
commit
1e9a53da3f
  1. 10
      libi2pd/Destination.cpp
  2. 1
      libi2pd/Destination.h
  3. 9
      libi2pd/Streaming.cpp
  4. 1
      libi2pd/Streaming.h

10
libi2pd/Destination.cpp

@ -1191,6 +1191,16 @@ namespace client @@ -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):
RunnableService ("Destination"),
ClientDestination (GetIOService (), keys, isPublic, params)

1
libi2pd/Destination.h

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

9
libi2pd/Streaming.cpp

@ -1128,6 +1128,15 @@ namespace stream @@ -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)
{
m_Acceptor = acceptor; // we must set it immediately for IsAcceptorSet

1
libi2pd/Streaming.h

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

Loading…
Cancel
Save