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

Method onConnection

example/echoServerAsync.cc:31–42  ·  view source on GitHub ↗

连接建立或断开的回调函数

Source from the content-addressed store, hash-verified

29private:
30 // 连接建立或断开的回调函数
31 void onConnection(const TcpConnectionPtr &conn)
32 {
33 if (conn->connected())
34 {
35 LOG_INFO << "Connection UP : " << conn->peerAddress().toIpPort().c_str();
36 // LOG_INFO("Connection UP : %s", conn->peerAddress().toIpPort().c_str());
37 }
38 else
39 {
40 LOG_INFO << "Connection DOWN : " << conn->peerAddress().toIpPort().c_str();
41 }
42 }
43
44 // 可读写事件回调
45 void onMessage(const TcpConnectionPtr &conn, Buffer *buf, Timestamp time)

Callers

nothing calls this directly

Calls 2

toIpPortMethod · 0.80
connectedMethod · 0.45

Tested by

no test coverage detected