MCPcopy Create free account
hub / github.com/crossuo/crossuo / Read

Method Read

src/Wisp/WispConnection.cpp:92–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92bool CConnection::Read(int maxSize)
93{
94 if (DataReady == -1)
95 {
96 Error(Network, "CConnection::Read, m_DataReady=%i", DataReady);
97 Disconnect();
98 }
99 else if (Connected && m_Socket != nullptr)
100 {
101 std::vector<uint8_t> data(maxSize);
102 const int size = tcp_recv(m_Socket, &data[0], maxSize);
103
104 if (size > 0)
105 {
106 //TRACE(Network, "CConnection::Read size=%i", size);
107 data.resize(size);
108 data = Decompression(data);
109 m_MessageParser->Append(data);
110 return true;
111 }
112
113 Error(Network, "CConnection::Read, bad size=%i", size);
114 }
115 else
116 {
117 Error(Network, "CConnection::Read, unknown state, m_Connected=%i", Connected);
118 }
119 return false;
120}
121
122int CConnection::Send(uint8_t *data, int size)
123{

Callers 1

RecvMethod · 0.45

Calls 4

ErrorFunction · 0.85
tcp_recvFunction · 0.85
resizeMethod · 0.80
AppendMethod · 0.80

Tested by

no test coverage detected