本文整理汇总了C++中Packet::GetOpCode方法的典型用法代码示例。如果您正苦于以下问题:C++ Packet::GetOpCode方法的具体用法?C++ Packet::GetOpCode怎么用?C++ Packet::GetOpCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet::GetOpCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PacketHandlerLoop
THREAD_FUNC PacketHandler::PacketHandlerLoop( void* packetHandler )
{
if ( NetworkControl::GetSingleton()->GetFlags() & NetworkControl::HANDLER_SYNC )
{
return 1;
}
PacketHandler* ph = (PacketHandler*) packetHandler;
while ( true )
{
ph->m_PacketQueueSemaphore.Wait( INFINITE );
if ( NetworkControl::GetSingleton()->m_StopRequestedEvent.Wait( 0 ) == true ||
ph->m_ParentClient->m_StopEvent.Wait( 0 ) == true )
{
break;
}
ph->m_PacketAdditionMutex.Lock();
// Get a packet from the queue.
Packet* handlePacket = ph->m_PacketQueue.front();
ph->m_PacketQueue.pop();
ph->m_PacketAdditionMutex.Unlock();
// Handle the packet if its operation code is recognized
OpCodeHandler::GetSingleton()->CallOpCodeFunction( handlePacket->GetOpCode(), handlePacket );
delete handlePacket;
}
return 1;
}
示例2: HandlePackets
unsigned int PacketHandler::HandlePackets( void )
{
if ( !( NetworkControl::GetSingleton()->GetFlags() & NetworkControl::HANDLER_SYNC ) )
{
return 0;
}
unsigned int amount = 0;
m_PacketAdditionMutex.Lock();
while ( m_PacketQueue.size() > 0 )
{
// Get a packet from the queue.
Packet* handlePacket = m_PacketQueue.front();
m_PacketQueue.pop();
// Handle the packet if its operation code is recognized
OpCodeHandler::GetSingleton()->CallOpCodeFunction( handlePacket->GetOpCode(), handlePacket );
delete handlePacket;
amount++;
}
m_PacketAdditionMutex.Unlock();
return amount;
}