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

Method onMessage

example/echoServer.cc:44–51  ·  view source on GitHub ↗

可读写事件回调

Source from the content-addressed store, hash-verified

42
43 // 可读写事件回调
44 void onMessage(const TcpConnectionPtr &conn, Buffer *buf, Timestamp time)
45 {
46 std::string msg = buf->retrieveAllAsString();
47 LOG_INFO << conn->name() << " echo " << msg.size() << " bytes, "
48 << "data received at " << time.toFormattedString();
49 conn->send(msg);
50 // conn->shutdown(); // 关闭写端 底层响应EPOLLHUP => 执行closeCallback_
51 }
52
53 EventLoop *loop_;
54 TcpServer server_;

Callers

nothing calls this directly

Calls 5

sizeMethod · 0.80
toFormattedStringMethod · 0.80
sendMethod · 0.80
retrieveAllAsStringMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected