本文整理汇总了C++中MessagePtr::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ MessagePtr::Get方法的具体用法?C++ MessagePtr::Get怎么用?C++ MessagePtr::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessagePtr
的用法示例。
在下文中一共展示了MessagePtr::Get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
NetServer::onStateMessage( MessagePtr m )
{
K_ASSERT( m.Get() != 0 );
NetStateMessage* nsm = static_cast<NetStateMessage*>( m.Get() );
switch ( nsm->state )
{
case NetStateMessage::TCP_CLOSED:
{
NetGroupMap::iterator i = m_groups.find( nsm->groupId );
if ( i != m_groups.end() )
{
NetGroup* group = i->second;
if ( group != 0 )
{
group->Leave( nsm->connectionId );
}
}
}
break;
}
m_listener->Notify( m );
}
示例2:
void
NetClient::Send( MessagePtr m )
{
K_ASSERT( m.Get() != 0 );
m_sendQ.Put( m );
}
示例3: 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 );
}
示例4: i
void
NetClient::onGroupJoin( MessagePtr m )
{
K_ASSERT( m_groupId != 0 );
NmGroupJoin* join = static_cast<NmGroupJoin*>( m.Get() );
K_ASSERT( join->groupId == m_groupId );
LOG( FT_DEBUG,
_T("NetClient::onGroupJoin> Group %d Members %d"),
join->groupId,
join->members.size() );
NmGroupJoin::MemberList::iterator i( join->members.begin() );
NmGroupJoin::MemberList::iterator iEnd( join->members.end() );
for ( ; i != iEnd; ++i )
{
NetGroupMember& member = *i;
if ( member.connectionId != m_selfTag )
{
UdpConnection* c = m_udp.FindByTag( member.connectionId );
if ( c != 0 )
{
continue;
}
// tag is used for communication
(void)m_udp.Connect( member.connectionId, member.in, member.ex );
NmGroupJoined* joined = new NmGroupJoined;
joined->groupId = join->groupId;
joined->connectionId = member.connectionId;
joined->extra = member.extra;
m_listener->Notify( MessagePtr( joined ) );
LOG( FT_DEBUG,
_T("NetClient::onGroupJoin> Self %d Tag %d joined In %s Ex %s"),
m_selfTag,
member.connectionId,
member.in.ToString().c_str(),
member.ex.ToString().c_str() );
}
}
}