本文整理汇总了C++中Packet::Execute方法的典型用法代码示例。如果您正苦于以下问题:C++ Packet::Execute方法的具体用法?C++ Packet::Execute怎么用?C++ Packet::Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet::Execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecvPacket
BOOL DBThread::ProcessCacheCommand()
{
PlayerID_t PlayerID ;
_MY_TRY
{
BOOL ret = FALSE ;
Packet* pPacket = NULL ;
ret = RecvPacket( pPacket, PlayerID);
if( !ret )
return TRUE ;
Player* pPlayer = g_pPlayerPool->GetPlayer( PlayerID ) ;
if( pPlayer )
{
pPacket->Execute(pPlayer) ;
}
else
{
pPacket->Execute(NULL);
}
g_pPacketFactoryManager->RemovePacket( pPacket ) ;
return TRUE;
}
_MY_CATCH
{
g_pLog->FastSaveLog(LOG_FILE_0,"DBThread::ProcessCacheCommand Get Errors,TID=%d,PlayerID =%d",getTID(),PlayerID);
return TRUE;
}
}
示例2: ProcessCommand
/**
*处理接入的数据包,解密包,分解包,执行包的操作
*\return 返回操作是否成功
*/
bool Player::ProcessCommand( bool option )
{
bool ret = false;
CHAR header[PACKET_HEADER_SIZE];
PacketID_t packetID;
UINT packetuint = 0;
UINT packetSize = 0;
UINT packetIndex = 0;
UINT packetTick = 0;
//Packet* pPacket = NULL;
if( IsDisconnect())
return true;
if(option)
{
}
for( ;; )
{
CHAR compart[PACK_COMPART_SIZE]={0};
if(!m_pSocketInputStream->Find(compart))
break;
if(!m_pSocketInputStream->Peek(&header[0], PACKET_HEADER_SIZE))
{
break;
}
memcpy( &packetID, &header[0], sizeof(PacketID_t) );
memcpy( &packetTick, &header[sizeof(PacketID_t)], sizeof(UINT) );
memcpy( &packetuint, &header[sizeof(UINT) + sizeof(PacketID_t)], sizeof(UINT) );
packetSize = GET_PACKET_LEN(packetuint);
packetIndex = GET_PACKET_INDEX(packetuint);
std::cout<<" PacketID:"<<packetID<<" packetTick:"<<packetTick<<" packetuint:"<<packetuint<<" packetSize:"<<packetSize<<" packetIndex:"<<packetIndex<<std::endl;
if(packetID >= (PacketID_t)PACKET_MAX)
{
Assert(false);
return false;
}
//消息解密
//
//
if( m_pSocketInputStream->Length()<PACKET_HEADER_SIZE+packetSize)
{
g_pLog->log_debug("%u,%u,m_pSocketInputStream->Length < ...",0,0);
break;
}
Packet* pPacket = g_pPacketFactoryManager->CreatePacket(packetID);
if(pPacket == NULL)
{
Assert(false);
return false;
}
std::cout<<"Create packet success\n";
pPacket->SetPacketIndex(packetIndex);
ret = m_pSocketInputStream->ReadPacket(pPacket);
if(ret==false)
{
Assert(false);
g_pPacketFactoryManager->RemovePacket(pPacket);
return false;
}
bool bNeedRemove = true;
//this->ResetKick( );
//执行包操作
UINT uret = pPacket->Execute( this );
if(uret == PACKET_EXE_ERROR)
{
if(pPacket)
g_pPacketFactoryManager->RemovePacket(pPacket);
return false;
}
else if(uret == PACKET_EXE_BREAK)
{
if(pPacket)
g_pPacketFactoryManager->RemovePacket(pPacket);
break;
}
else if(uret==PACKET_EXE_CONTINUE)
{//继续解析剩下消息
}
//.........这里部分代码省略.........