MCPcopy Create free account
hub / github.com/caozhiyi/CppNet / ReadFunc

Function ReadFunc

test/simple/CppNetClient.cpp:24–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24void ReadFunc(const Handle& handle, base::CBuffer* data, uint32_t len, uint32_t error) {
25 if (error != CEC_CLOSED && error != CEC_CONNECT_BREAK) {
26 std::cout << " [ReadFunc]" << std::endl;
27 std::cout << *(data) << std::endl;
28 data->Clear();
29 std::cout << " Thread ID : " << std::this_thread::get_id() << std::endl;
30 std::cout << " Read size : " << len << std::endl << std::endl;
31 base::CRunnable::Sleep(1000);
32
33 if (index > 5) {
34 handle->Close();
35 return;
36 }
37
38 auto msg = GetMsg();
39 handle->Write(msg.c_str(), msg.length());
40
41 } else {
42 std::cout << "Close" << std::endl;
43 }
44}
45
46void ConnectFunc(const Handle& handle, uint32_t err) {
47 if (err == CEC_SUCCESS) {

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.80
GetMsgFunction · 0.70
ClearMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected