| 24 | } |
| 25 | |
| 26 | void EchoServer::onConnection(const TcpConnectionPtr& conn) |
| 27 | { |
| 28 | LOG_INFO << "EchoServer - " << conn->peerAddress().toIpPort() << " -> " |
| 29 | << conn->localAddress().toIpPort() << " is " |
| 30 | << (conn->connected() ? "UP" : "DOWN"); |
| 31 | |
| 32 | if (conn->connected()) |
| 33 | { |
| 34 | ++numConnected_; |
| 35 | if (numConnected_ > kMaxConnections_) |
| 36 | { |
| 37 | conn->shutdown(); |
| 38 | conn->forceCloseWithDelay(3.0); // > round trip of the whole Internet. |
| 39 | } |
| 40 | } |
| 41 | else |
| 42 | { |
| 43 | --numConnected_; |
| 44 | } |
| 45 | LOG_INFO << "numConnected = " << numConnected_; |
| 46 | } |
| 47 | |
| 48 | void EchoServer::onMessage(const TcpConnectionPtr& conn, |
| 49 | Buffer* buf, |
nothing calls this directly
no test coverage detected