MCPcopy Create free account
hub / github.com/Shangyizhou/A-Tiny-Network-Library / onMessage

Method onMessage

example/echoServerAsync.cc:45–51  ·  view source on GitHub ↗

可读写事件回调

Source from the content-addressed store, hash-verified

43
44 // 可读写事件回调
45 void onMessage(const TcpConnectionPtr &conn, Buffer *buf, Timestamp time)
46 {
47 printf("onMessage!\n");
48 std::string msg = buf->retrieveAllAsString();
49 conn->send(msg);
50 // conn->shutdown(); // 关闭写端 底层响应EPOLLHUP => 执行closeCallback_
51 }
52
53 EventLoop *loop_;
54 TcpServer server_;

Callers

nothing calls this directly

Calls 2

sendMethod · 0.80
retrieveAllAsStringMethod · 0.45

Tested by

no test coverage detected