本文整理汇总了C++中TcpConnection::GetSocket方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnection::GetSocket方法的具体用法?C++ TcpConnection::GetSocket怎么用?C++ TcpConnection::GetSocket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnection
的用法示例。
在下文中一共展示了TcpConnection::GetSocket方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MessagePtr
void
NetClient::onGroupPrepare( MessagePtr m )
{
K_ASSERT( m_groupId == 0 );
K_ASSERT( m_selfTag == 0 );
m_groupId = 0;
m_selfTag = 0;
NmGroupPrepare* gp = static_cast<NmGroupPrepare*>( m.Get() );
TcpConnection* c = m_tcp.FindById( gp->remote );
if ( c == 0 )
{
LOG( FT_WARN,
_T("NetClient::onGroupPrepare> Connection %d not found"),
gp->remote );
return;
}
m_udp.Fini();
m_groupId = gp->groupId;
m_selfTag = gp->connectionId;
// init udp with c as a relay connection
// use same ip:port as TCP connection
bool rc = m_udp.Init( this,
&m_ios,
c->GetSocket()->GetAddress(),
m_selfTag,
gp->sl,
gp->challenge,
c );
if ( !rc )
{
LOG( FT_WARN, _T("NetClient::onGroupPrepare> Failed to init udp") );
return;
}
NmGroupPrepared* p = new NmGroupPrepared;
p->remote = gp->remote;
p->groupId = gp->groupId;
p->connectionId = gp->connectionId;
p->in = c->GetSocket()->GetAddress();
m_tcp.Send( m->remote, MessagePtr( p ) );
LOG( FT_DEBUG, _T("NetClient::onGroupPrepare> Prepared group %d connection %d"),
gp->groupId,
gp->connectionId );
}
示例2:
void
NetServer::onJoinUdpGroup( const NetGroupOp& op )
{
NetGroupMap::iterator i = m_groups.find( op.groupId );
if ( i == m_groups.end() )
{
LOG( FT_WARN, _T("NetServer::onJoinUdpGroup> %d not found"), op.groupId );
// TODO: error report
return;
}
TcpConnection* c = m_tcp.FindById( op.connectionId );
if ( c == 0 )
{
LOG( FT_WARN,
_T("NetServer::onJoinUdpGroup> Connection %d not found"),
op.connectionId );
return;
}
NetGroup* group = i->second;
K_ASSERT( group != 0 );
c->SetGroup( op.groupId );
(void)group->Join( op.connectionId, c->GetSocket()->GetPeerAddress(), op.extra );
LOG( FT_DEBUG,
_T("NetServer::onJoinUdpGroup> %d joined to %d"),
op.connectionId, group->GetId() );
}