| 39 | |
| 40 | private: |
| 41 | void onConnection(const TcpConnectionPtr& conn) |
| 42 | { |
| 43 | LOG_INFO << conn->peerAddress().toIpPort() << " -> " |
| 44 | << conn->localAddress().toIpPort() << " is " |
| 45 | << (conn->connected() ? "UP" : "DOWN"); |
| 46 | |
| 47 | MutexLockGuard lock(mutex_); |
| 48 | if (!connections_.unique()) |
| 49 | { |
| 50 | connections_.reset(new ConnectionList(*connections_)); |
| 51 | } |
| 52 | assert(connections_.unique()); |
| 53 | |
| 54 | if (conn->connected()) |
| 55 | { |
| 56 | connections_->insert(conn); |
| 57 | } |
| 58 | else |
| 59 | { |
| 60 | connections_->erase(conn); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | typedef std::set<TcpConnectionPtr> ConnectionList; |
| 65 | typedef std::shared_ptr<ConnectionList> ConnectionListPtr; |