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


C++ CNetMessage::Deserialize方法代码示例

本文整理汇总了C++中CNetMessage::Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C++ CNetMessage::Deserialize方法的具体用法?C++ CNetMessage::Deserialize怎么用?C++ CNetMessage::Deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CNetMessage的用法示例。


在下文中一共展示了CNetMessage::Deserialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateMessage

CNetMessage* CNetMessageFactory::CreateMessage(const void* pData,
											   size_t dataSize,
											   ScriptInterface& scriptInterface)
{
	CNetMessage* pNewMessage = NULL;
	CNetMessage header;

	// Figure out message type
	header.Deserialize((const u8*)pData, (const u8*)pData + dataSize);

	switch (header.GetType())
	{
	case NMT_GAME_SETUP:
		pNewMessage = new CGameSetupMessage(scriptInterface);
		break;

	case NMT_PLAYER_ASSIGNMENT:
		pNewMessage = new CPlayerAssignmentMessage;
		break;

	case NMT_FILE_TRANSFER_REQUEST:
		pNewMessage = new CFileTransferRequestMessage;
		break;

	case NMT_FILE_TRANSFER_RESPONSE:
		pNewMessage = new CFileTransferResponseMessage;
		break;

	case NMT_FILE_TRANSFER_DATA:
		pNewMessage = new CFileTransferDataMessage;
		break;

	case NMT_FILE_TRANSFER_ACK:
		pNewMessage = new CFileTransferAckMessage;
		break;

	case NMT_JOIN_SYNC_START:
		pNewMessage = new CJoinSyncStartMessage;
		break;

	case NMT_REJOINED:
		pNewMessage = new CRejoinedMessage;
		break;

	case NMT_KICKED:
		pNewMessage = new CKickedMessage;
		break;

	case NMT_LOADED_GAME:
		pNewMessage = new CLoadedGameMessage;
		break;

	case NMT_SERVER_HANDSHAKE:
		pNewMessage = new CSrvHandshakeMessage;
		break;

	case NMT_SERVER_HANDSHAKE_RESPONSE:
		pNewMessage = new CSrvHandshakeResponseMessage;
		break;

	case NMT_CLIENT_HANDSHAKE:
		pNewMessage = new CCliHandshakeMessage;
		break;

	case NMT_AUTHENTICATE:
		pNewMessage = new CAuthenticateMessage;
		break;

	case NMT_AUTHENTICATE_RESULT:
		pNewMessage = new CAuthenticateResultMessage;
		break;

	case NMT_GAME_START:
		pNewMessage = new CGameStartMessage;
		break;

	case NMT_END_COMMAND_BATCH:
		pNewMessage = new CEndCommandBatchMessage;
		break;

	case NMT_SYNC_CHECK:
		pNewMessage = new CSyncCheckMessage;
		break;

	case NMT_SYNC_ERROR:
		pNewMessage = new CSyncErrorMessage;
		break;

	case NMT_CHAT:
		pNewMessage = new CChatMessage;
		break;

	case NMT_READY:
		pNewMessage = new CReadyMessage;
		break;

	case NMT_SIMULATION_COMMAND:
		pNewMessage = new CSimulationMessage(scriptInterface);
		break;

//.........这里部分代码省略.........
开发者ID:Gavinator98,项目名称:0ad,代码行数:101,代码来源:NetMessage.cpp


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