本文整理汇总了C++中CNetMsg::SetTime方法的典型用法代码示例。如果您正苦于以下问题:C++ CNetMsg::SetTime方法的具体用法?C++ CNetMsg::SetTime怎么用?C++ CNetMsg::SetTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNetMsg
的用法示例。
在下文中一共展示了CNetMsg::SetTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_msg
bool CServer::parse_msg(RakNet::Packet* packet)
{
#pragma region DEBUG_OUTPUT
#if DB_NET_MSG_CNT
switch (packet->data[0])
{
case ID_NEW_INCOMING_CONNECTION:{
printf("S : Incoming Connection from: \t\t%s\n", packet->systemAddress.ToString());
break; }
case ID_DISCONNECTION_NOTIFICATION:{
printf("S : Disconnection from: \t\t%s\n", packet->systemAddress.ToString());
break; }
case ID_CONNECTION_LOST:{
printf("S : Lost Connection from: \t\t%s\n", packet->systemAddress.ToString());
break; }
case ID_UNCONNECTED_PING:{
printf("S : Received Ping Broadcast from: \t%s\n", packet->systemAddress.ToString());
break; }
case ID_TIMESTAMP:{
printf("S : Received Msg from: \t\t\t%s\n", packet->systemAddress.ToString());
break; }
default: {
printf("S : Received Identifier %i from: \t\t%s\n", packet->data[0], packet->systemAddress.ToString());
break; }
}
#endif
#pragma endregion
//Set Msg Type
CNetMsg msg = CNetMsg(ENetMsg(packet->data[0]));
//If connecting client then give an id
if (packet->data[0] == ID_NEW_INCOMING_CONNECTION)
{
this->connect_client(packet);
}
//Get Peer Data
TPeer peer;
peer.m_Addr = packet->systemAddress;
peer.m_Guid = packet->guid;
ulong size = this->m_vClients.size();
for (ulong i = 0; i < size; ++i)
{
if (this->m_vClients[i].m_Guid == peer.m_Guid)
{
peer.m_scID = schar(i);
break;
}
}
msg.SetPeer(peer);
//If user type, then get data
if (packet->data[0] == ID_TIMESTAMP)
{
//Get the header parts of the packet
RakNet::BitStream bsIn(packet->data, packet->length, false);
uchar useTimeStamp;
RakNet::Time timeStamp;
uchar typeID;
//Read them in
bsIn.Read((RakNet::MessageID)useTimeStamp);
bsIn.Read(timeStamp);
bsIn.Read((RakNet::MessageID)typeID);
ulong offset = bsIn.GetReadOffset() / 8;
//Parse into a CNetMsg
msg.SetType(ENetMsg(typeID));
msg.WriteRaw((const char*)(packet->data + offset), ushort(packet->length - offset));
msg.SetTime(timeStamp);
#if DB_NET_MSG_SR
printf(" : Client #%d\n", peer.m_scID);
printf(" : Msg Type:\t%s\n", ENetMsgStr(msg.GetType()));
printf(" : Msg Size:\t%d\n", msg.GetWrite());
printf(" : Msg Time:\t%d\n", msg.GetTime());
#endif
}
//Add msg to vector
this->m_vMsgs.push_back(msg);
return true;
}