本文整理汇总了C++中NetworkMessage::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkMessage::getLength方法的具体用法?C++ NetworkMessage::getLength怎么用?C++ NetworkMessage::getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkMessage
的用法示例。
在下文中一共展示了NetworkMessage::getLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: malloc
NetworkMessageV2::NetworkMessageV2 (const NetworkMessage& nm)
{
if (nm.getVersion() == 2) {
_pBuf = (char *) malloc (nm.getLength());
memcpy (_pBuf, nm.getBuf(), nm.getLength());
_ui16NetMsgLen = nm.getLength();
}
else {
uint8 ui8Version = nm.getVersion();
uint8 ui8MsgType = nm.getMsgType();
uint32 ui32SourceAddress = nm.getSourceAddress();
uint32 ui32TargetAddress = nm.getTargetAddress();
uint16 ui16SessionId = nm.getSessionId();
uint16 ui16MsgId = nm.getMsgId();
uint8 ui8HopCount = nm.getHopCount();
uint8 ui8TTL = nm.getTTL();
ChunkType chunkType = (ChunkType) nm.getChunkType();
bool bReliable = nm.isReliableMsg();
const void *pMsgMetaData = nm.getMetaData();
uint16 ui16MsgMetaDataLen = nm.getMetaDataLen();
const void *pMsg = nm.getMsg();
uint16 ui16MsgLen = nm.getMsgLen();
uint8 ui8QueueSize = 0;
create (ui8MsgType, ui32SourceAddress, ui32TargetAddress, ui16SessionId,
ui16MsgId, ui8HopCount, ui8TTL, chunkType, bReliable,
pMsgMetaData, ui16MsgMetaDataLen, pMsg, ui16MsgLen, 0);
}
}
示例2: writeToOutputBuffer
void ProtocolSpectator::writeToOutputBuffer(const NetworkMessage& msg)
{
OutputMessage_ptr out = getOutputBuffer(msg.getLength());
if (out) {
out->append(msg);
}
}
示例3: parsePacket
void ProtocolSpectator::parsePacket(NetworkMessage& msg)
{
if (!m_acceptPackets || g_game.getGameState() == GAME_STATE_SHUTDOWN || msg.getLength() <= 0) {
return;
}
uint8_t recvbyte = msg.getByte();
if (!player) {
if (recvbyte == 0x0F) {
disconnect();
}
return;
}
//a dead player can not perform actions
if (player->isRemoved() || player->getHealth() <= 0) {
disconnect();
return;
}
switch (recvbyte) {
case 0x14: g_dispatcher.addTask(createTask(std::bind(&ProtocolSpectator::logout, this))); break;
case 0x1D: g_dispatcher.addTask(createTask(std::bind(&ProtocolSpectator::sendPingBack, this))); break;
case 0x1E: g_dispatcher.addTask(createTask(std::bind(&ProtocolSpectator::sendPing, this))); break;
//Reset viewed position/direction if the spectator tries to move in any way
case 0x65: case 0x66: case 0x67: case 0x68: case 0x69: case 0x6A: case 0x6B: case 0x6C: case 0x6D: case 0x6E: case 0x6F: case 0x70: case 0x71:
case 0x72: g_dispatcher.addTask(createTask(std::bind(&ProtocolSpectator::sendCancelWalk, this))); break;
case 0x96: parseSpectatorSay(msg); break;
default:
break;
}
if (msg.isOverrun()) {
disconnect();
}
}