本文整理汇总了C++中TcpConnectionPtr::connected方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnectionPtr::connected方法的具体用法?C++ TcpConnectionPtr::connected怎么用?C++ TcpConnectionPtr::connected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnectionPtr
的用法示例。
在下文中一共展示了TcpConnectionPtr::connected方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnConnection
void OnConnection(const TcpConnectionPtr& conn)
{
LOG_INFO << conn->localAddress().toIpPort() << " -> "
<< conn->peerAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if(conn->connected())
{
m_connection = conn;
if(g_aliveConnections.incrementAndGet() == g_connections)
{
LOG_INFO << "all connected";
}
else
{
m_connection.reset();
if(g_aliveConnections.incrementAndGet() == g_connections)
{
LOG_INFO << "all disconnected";
g_loop->quit();
}
}
}
}
示例2: onConnection
void onConnection(const TcpConnectionPtr& conn){
LOG_INFO << conn->localAddress().toIpPort() << " -> "
<< conn->peerAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if(!conn->connected())
loop_->quit();
}
示例3: onJsonConnection
/***************************************************
Description: 处理新的json连接或者连接断开情况
Input: conn:TCP连接
Output: 无
Return: 无
***************************************************/
void TCPServer::onJsonConnection(const TcpConnectionPtr &conn)
{
LOG_DEBUG <<"JSONConnection: " << conn->peerAddress().toIpPort() << " -> "
<< conn->localAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if(!conn->connected())
jsonCodec_.cleanup(conn);
}
示例4: onServerConnection
/***************************************************
Description: 处理新的TCP连接或断开
Input: 无
Output: 无
Return: 无
***************************************************/
void TCPServer::onServerConnection(const TcpConnectionPtr& conn)
{
conn->setTcpNoDelay(true);
LOG_INFO << conn->peerAddress().toIpPort() << " -> "
<< conn->localAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if(!conn->connected())
{
clearConnectionInfo(conn);
}
}
示例5: serverConnectionCallback
void serverConnectionCallback(const TcpConnectionPtr& conn)
{
LOG_TRACE << conn->name() << " " << conn->peerAddress().toIpPort() << " -> "
<< conn->localAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if (conn->connected())
{
conn->setTcpNoDelay(true);
}
else
{
}
}
示例6: onConnection
void onConnection(const TcpConnectionPtr& conn){
LOG_INFO << "FileServer - " << conn->peerAddress().toIpPort() << " -> "
<< conn->localAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if(conn->connected()){
LOG_INFO << "FileServer - Sending file " << g_file
<< " to " << conn->peerAddress().toIpPort();
conn->setHighWaterMarkCallback(onHighWaterMark, 64*1024);
string fileContent = readFile(g_file);
conn->send(fileContent);
conn->shutdown();
LOG_INFO << "FileServer - done";
}
}
示例7: onConnection
void onConnection(const TcpConnectionPtr& conn)
{
cout << conn->peerAddress().ipPort() << " -> " << conn->localAddress().ipPort()
<< " is " << (conn->connected() ? "UP" : "DOWN") << "\n";
clientConnection = conn;
if (conn->connected())
{
//conn->setNoDelay(true);
}
else
{
//clientConnection.reset();
}
}
示例8: clientConnectionCallback
void clientConnectionCallback(const TcpConnectionPtr& conn)
{
LOG_TRACE << conn->localAddress().toIpPort() << " -> "
<< conn->peerAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if (conn->connected())
{
clientConnection = conn;
conn->setTcpNoDelay(true);
}
else
{
clientConnection.reset();
}
}
示例9: onConnection
void EchoServer::onConnection(const TcpConnectionPtr& conn){
LOG_INFO << "EchoServer - " << conn->peerAddress().toIpPort() << " -> "
<< conn->localAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if(conn->connected()){
++numConnected_;
if(numConnected_ > kMaxConnections_){
conn->shutdown();
conn->forceCloseWithDelay(3.0); // > round trip of the whole Internet.
}
}else{
--numConnected_;
}
LOG_INFO << "numConnected = " << numConnected_;
}
示例10: onConnection
void MyTcpClient::onConnection(const TcpConnectionPtr& conn)
{
LOG_INFO << conn->localAddress().toIpPort() << " -> "
<< conn->peerAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
MutexLockGuard lock(mutex_);
if (conn->connected())
{
connection_ = conn;
}
else
{
connection_.reset();
}
}
示例11: onConnection
void Sender::onConnection(const TcpConnectionPtr& conn)
{
LOG_INFO << "EchoServer - " << conn->peerAddress().toIpPort() << " -> "
<< conn->localAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
}
示例12: defaultConnectionCallback
NAMESPACE_ZL_NET_START
void defaultConnectionCallback(const TcpConnectionPtr& conn)
{
LOG_INFO("defaultConnectionCallback : [%s]<->[%s] [%s]\n", conn->localAddress().ipPort().c_str(),
conn->peerAddress().ipPort().c_str(), conn->connected() ? "UP" : "DOWN");
}
示例13: onConnection
void onConnection(const TcpConnectionPtr& conn)
{
LOG_TRACE << conn->localAddress().toIpPort() << " -> "
<< conn->peerAddress().toIpPort() << " is "
<< (conn->connected() ? "UP" : "DOWN");
if (conn->connected())
{
conn->setTcpNoDelay(true);
conn->send(message_);
}
else
{
loop_->quit();
}
}
示例14: onConnection
//新连接或断开时的回调
void onConnection(const TcpConnectionPtr &conn)
{
LOG_INFO <<conn->localAddress().toIpPort() << "->"
<<conn->peerAddress().toIpPort() << "is"
<<(conn->connected() ? "UP" : "DOWN");
if(conn->connected())
{
//插入到用户集合中
connections_.insert(conn);
}
else
{
//从集合中删除用户
connections_.erase(conn);
}
}
示例15: onConnection
void HttpServer::onConnection(const TcpConnectionPtr& conn)
{
LOG_INFO("HttpServer::onConnection get one client %d", conn->fd());
if (conn->connected())
{
conn->setContext(HttpContext());
}
}