本文整理汇总了C++中ConnectionPtr::isConnected方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionPtr::isConnected方法的具体用法?C++ ConnectionPtr::isConnected怎么用?C++ ConnectionPtr::isConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionPtr
的用法示例。
在下文中一共展示了ConnectionPtr::isConnected方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addConnection
void ConnectionSet::addConnection( ConnectionPtr connection )
{
LBASSERT( connection->isConnected() || connection->isListening( ));
{
lunchbox::ScopedWrite mutex( _impl->lock );
_impl->allConnections.push_back( connection );
#ifdef _WIN32
LBASSERT( _impl->allConnections.size() <
MAX_CONNECTIONS * MAX_CONNECTIONS );
if ( !_isThreadMode && _impl->connections.size() < MAX_CONNECTIONS )
{
_impl->connections.push_back( connection );
}
else
{
_addConnectionToThread( connection );
}
#else
connection->addListener( _impl );
LBASSERT( _impl->allConnections.size() < MAX_CONNECTIONS );
#endif // _WIN32
}
setDirty();
}
示例2: _connect
bool LocalNode::_connect( NodePtr node, ConnectionPtr connection )
{
EQASSERT( connection.isValid( ));
EQASSERT( node->getNodeID() != getNodeID( ));
if( !node.isValid() || _state != STATE_LISTENING ||
!connection->isConnected() || node->_state != STATE_CLOSED )
{
return false;
}
_addConnection( connection );
// send connect packet to peer
NodeConnectPacket packet;
packet.requestID = registerRequest( node.get( ));
packet.nodeID = _id;
packet.nodeType = getType();
connection->send( packet, serialize( ));
bool connected = false;
if( !waitRequest( packet.requestID, connected, 10000 /*ms*/ ))
{
EQWARN << "Node connection handshake timeout - peer not a Collage node?"
<< std::endl;
return false;
}
if( !connected )
return false;
EQASSERT( node->_id != NodeID::ZERO );
EQASSERTINFO( node->_id != _id, _id );
EQINFO << node << " connected to " << *(Node*)this << std::endl;
return true;
}
示例3: addConnection
void ConnectionSet::addConnection( ConnectionPtr connection )
{
LBASSERT( connection->isConnected() || connection->isListening( ));
{
lunchbox::ScopedWrite mutex( _impl->lock );
_impl->allConnections.push_back( connection );
#ifdef _WIN32
LBASSERT( _impl->allConnections.size() <
MAX_CONNECTIONS * MAX_CONNECTIONS );
if( _impl->connections.size() < MAX_CONNECTIONS - _impl->threads.size())
{
// can handle it ourself
_impl->connections.push_back( connection );
connection->addListener( this );
}
else
{
// add to existing thread
for( ThreadsCIter i = _impl->threads.begin();
i != _impl->threads.end(); ++i )
{
Thread* thread = *i;
if( thread->set->getSize() > MAX_CONNECTIONS )
continue;
thread->set->addConnection( connection );
return;
}
// add to new thread
Thread* thread = new Thread( this );
thread->set->addConnection( connection );
thread->set->addConnection( _impl->connections.back( ));
_impl->connections.pop_back();
_impl->threads.push_back( thread );
thread->start();
}
#else
_impl->connections.push_back( connection );
connection->addListener( this );
LBASSERT( _impl->connections.size() < MAX_CONNECTIONS );
#endif // _WIN32
}
setDirty();
}
示例4: _removeConnection
void LocalNode::_removeConnection( ConnectionPtr connection )
{
EQASSERT( connection.isValid( ));
_incoming.removeConnection( connection );
void* buffer( 0 );
uint64_t bytes( 0 );
connection->getRecvData( &buffer, &bytes );
EQASSERTINFO( !connection->isConnected() || buffer, *connection );
EQASSERT( !buffer || bytes == sizeof( uint64_t ));
if( !connection->isClosed( ))
connection->close(); // cancels pending IO's
delete reinterpret_cast< uint64_t* >( buffer );
}