本文整理汇总了C++中TcpConnectionPtr::getServerConnCount方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnectionPtr::getServerConnCount方法的具体用法?C++ TcpConnectionPtr::getServerConnCount怎么用?C++ TcpConnectionPtr::getServerConnCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnectionPtr
的用法示例。
在下文中一共展示了TcpConnectionPtr::getServerConnCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onTcpConnected
void AppBusiness::onTcpConnected(const TcpConnectionPtr& connection)
{
logger().writeFmt("onTcpConnected (%s) (ConnCount: %d)",
connection->getPeerAddr().getDisplayStr().c_str(),
connection->getServerConnCount());
connection->recv();
}
示例2: onTcpConnected
//-----------------------------------------------------------------------------
// 描述: 接受了一个新的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: onTcpConnected
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: onTcpConnected
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: onTcpConnected
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: onTcpConnected
//-----------------------------------------------------------------------------
// 描述: 接受了一个新的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);
}