void AppBusiness::onTcpConnected(const TcpConnectionPtr& connection) { logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)", connection->getPeerAddr().getDisplayStr().c_str(), connection->getServerConnCount()); connection->recv(); }
//----------------------------------------------------------------------------- // 描述: 接受了一个新的TCP连接 //----------------------------------------------------------------------------- void AppBusiness::onTcpConnected(const TcpConnectionPtr& connection) { logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)", connection->getPeerAddr().getDisplayStr().c_str(), connection->getServerConnCount()); string msg = "Welcome to the simple echo server, type 'quit' to exit.\r\n"; connection->send(msg.c_str(), msg.length()); }
void ServerModule_Daytime::onTcpConnected(const TcpConnectionPtr& connection) { logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)", connection->getPeerAddr().getDisplayStr().c_str(), connection->getServerConnCount()); string msg = DateTime::now().toDateTimeString() + "\n"; connection->send(msg.c_str(), msg.length()); }
void ServerModule_Chargen::onTcpConnected(const TcpConnectionPtr& connection) { logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)", connection->getPeerAddr().getDisplayStr().c_str(), connection->getServerConnCount()); connection->setNoDelay(true); connection->recv(); connection->send(message_.c_str(), message_.length()); }
void AppBusiness::onTcpConnected(const TcpConnectionPtr& connection) { const int MAX_CONN_COUNT = 3; logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)", connection->getPeerAddr().getDisplayStr().c_str(), connection->getServerConnCount()); int connCount = connection->getServerConnCount(); if (connCount > MAX_CONN_COUNT) { logger().writeFmt("Too many connections. (ConnCount: %d)", connCount); connection->disconnect(); } else { string msg = "Welcome to the simple echo server, type 'quit' to exit.\r\n"; connection->send(msg.c_str(), msg.length()); } }
//----------------------------------------------------------------------------- // 描述: 接受了一个新的TCP连接 //----------------------------------------------------------------------------- void AppBusiness::onTcpConnected(const TcpConnectionPtr& connection) { logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)", connection->getPeerAddr().getDisplayStr().c_str(), connection->getServerConnCount()); //string msg = "Welcome to the simple echo server, type 'quit' to exit.\r\n"; //ConnetManager::instance().add(connection); connection->recv(SELF_PACKET_SPLITTER, EMPTY_CONTEXT); }