MCPcopy Create free account
hub / github.com/MonaSolutions/MonaServer / TCPConnection

Method TCPConnection

UnitTests/sources/SocketTest.cpp:230–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228class TCPConnection {
229public:
230 TCPConnection(const SocketAddress& peerAddress,SocketFile& file,const SocketManager& manager) : _client(peerAddress,file, manager) {
231 onData = [this](PoolBuffer& pBuffer) {
232 Exception ex;
233 CHECK(_client.send(ex, pBuffer->data(), pBuffer->size()) && !ex);
234 return pBuffer->size();
235 };
236 onError = [this](const Exception& ex) {
237 FATAL_ERROR("Client, ",ex.error());
238 };
239 onDisconnection = [this](TCPClient& client, const SocketAddress& peerAddress){
240 CHECK(!_client.connected());
241 };
242 _client.OnError::subscribe(onError);
243 _client.OnData::subscribe(onData);
244 _client.OnDisconnection::subscribe(onDisconnection);
245 }
246
247 ~TCPConnection() {
248 _client.OnError::unsubscribe(onError);

Callers

nothing calls this directly

Calls 5

errorMethod · 0.80
sendMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
connectedMethod · 0.45

Tested by

no test coverage detected