本文整理汇总了C++中CNetMsg::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ CNetMsg::GetData方法的具体用法?C++ CNetMsg::GetData怎么用?C++ CNetMsg::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNetMsg
的用法示例。
在下文中一共展示了CNetMsg::GetData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetBroadcastResponse
bool CServer::SetBroadcastResponse(CNetMsg& msg)
{
//Early Out
if (this->m_pRak == NULL)
return false;
//Response can't be over 400 bytes
if (msg.GetWrite() > 400)
return false;
this->m_pRak->SetOfflinePingResponse(msg.GetData(), msg.GetWrite());
return true;
}
示例2: send_msg
bool CServer::send_msg(CNetMsg& msg, const TPeer& dest, const PacketPriority& prio, const PacketReliability& reli)
{
//Early Out
if (this->m_pRak == NULL)
return false;
//Duplicate to all clients
if (dest.m_scID == -1)
{
ulong size = this->m_vClients.size();
for (ulong i = 0; i < size; ++i)
{
if (!this->send_msg(msg, this->m_vClients[i], prio, reli))
return false;
}
return true;
}
//Parse msg to bitstream
RakNet::BitStream stream;
RakNet::Time timeStamp = RakNet::GetTime();
stream.Write(RakNet::MessageID(ID_TIMESTAMP));
stream.Write(timeStamp);
stream.Write(RakNet::MessageID(msg.GetType()));
stream.Write(msg.GetData(), msg.GetWrite());
#if DB_NET_MSG_SR
printf("S : Sending Msg to: \t\t\t%s\n", dest.m_Addr.ToString());
printf(" : Client #%d\n", dest.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", timeStamp);
#endif
return this->m_pRak->Send(&stream, prio, reli, 0, dest.m_Guid, false) != 0;
}