Пример #1
0
void AppBusiness::onTcpConnected(const TcpConnectionPtr& connection)
{
    logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)",
        connection->getPeerAddr().getDisplayStr().c_str(),
        connection->getServerConnCount());

    connection->recv();
}
Пример #2
0
//-----------------------------------------------------------------------------
// 描述: 接受了一个新的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());
}
Пример #3
0
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());
}
Пример #4
0
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());
}
Пример #5
0
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());
    }
}
Пример #6
0
//-----------------------------------------------------------------------------
// 描述: 接受了一个新的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);
}