当前位置: 首页>>代码示例>>C++>>正文


C++ NetworkMessage::getLength方法代码示例

本文整理汇总了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);
    }
}
开发者ID:agilecomputing,项目名称:nomads,代码行数:29,代码来源:NetworkMessageV2.cpp

示例2: writeToOutputBuffer

void ProtocolSpectator::writeToOutputBuffer(const NetworkMessage& msg)
{
	OutputMessage_ptr out = getOutputBuffer(msg.getLength());

	if (out) {
		out->append(msg);
	}
}
开发者ID:ricker75,项目名称:forgottenserver,代码行数:8,代码来源:protocolspectator.cpp

示例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();
	}
}
开发者ID:ricker75,项目名称:forgottenserver,代码行数:38,代码来源:protocolspectator.cpp


注:本文中的NetworkMessage::getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。