MCPcopy Create free account
hub / github.com/ReversecLabs/C3 / StartReceiving

Method StartReceiving

Src/Common/FSecure/Sockets/DuplexConnection.cpp:65–93  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

63
64////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
65void FSecure::DuplexConnection::StartReceiving(std::function<void(ByteVector)> callback)
66{
67 m_IsReceiving = true;
68 m_ReceivingThread = std::thread([this, callback]()
69 {
70 try
71 {
72 while (true)
73 {
74 if (m_IsReceiving && !m_ClientSocket.HasReceivedData())
75 {
76 std::this_thread::sleep_for(10ms);
77 continue;
78 }
79 if (!m_IsReceiving)
80 break;
81
82 auto message = Receive();
83 if (!m_IsReceiving || message.empty())
84 break;
85 callback(std::move(message));
86 }
87 }
88 catch (FSecure::SocketsException&)
89 {
90 Stop();
91 }
92 });
93}
94
95void FSecure::DuplexConnection::Stop()
96{

Callers 1

RunApiBrigeMethod · 0.80

Calls 2

HasReceivedDataMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected