当前位置: 首页>>代码示例>>C++>>正文


C++ MessagePtr::Get方法代码示例

本文整理汇总了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 );
}
开发者ID:criptych,项目名称:gamekernel,代码行数:28,代码来源:NetServer.cpp

示例2:

void 
NetClient::Send( MessagePtr m )
{
	K_ASSERT( m.Get() != 0 );

	m_sendQ.Put( m );
}
开发者ID:criptych,项目名称:gamekernel,代码行数:7,代码来源:NetClient.cpp

示例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 );
}
开发者ID:criptych,项目名称:gamekernel,代码行数:57,代码来源:NetClient.cpp

示例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() );
		}
	}
}
开发者ID:criptych,项目名称:gamekernel,代码行数:50,代码来源:NetClient.cpp


注:本文中的MessagePtr::Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。