private void MessageReceived(GameServer server, IProtocol message) { ISubProtocol pSubProtocol = message.GetSubProtocol(); if (pSubProtocol == null || (ProtocolDef)message.ProtocolId != ProtocolDef.l2e_header_def) { return; } byte[] data = message.ToBytes(); switch ((ProtocolDef)pSubProtocol.SubProtocolID) { // ahpho case ProtocolDef.l2e_update_custom_info_def: { l2e_update_custom_info protocal = new l2e_update_custom_info(); protocal.FromBytes(data); _customInfoStrs = protocal.GetInfoStrs(); } break; case ProtocolDef.l2e_PlayerCount_def: { l2e_PlayerCount protocol = new l2e_PlayerCount(); protocol.FromBytes(data); if (protocol.GetTotalCount() >= 0) { UpdatePlayerCount(protocol.GetTotalCount(),server.Group); } if (protocol.GetOffliveCount() >= 0) UpdateOfflineCount(protocol.GetOffliveCount()); } break; //GM指令接收的消息 case ProtocolDef.l2e_ExeGMCmd_def: { l2e_ExeGMCmd protocol = new l2e_ExeGMCmd(); protocol.FromBytes(data); //l2e_ExeGMCmd protocol = (l2e_ExeGMCmd)message; if (protocol.ReturnCode == 1) { UpdateGMResultCache(protocol.nSessionID, protocol.szResult); } else { UpdateGMResultCache(protocol.nSessionID, "GM指令操作失败"); } } break; case ProtocolDef.l2e_GetBasicInfo_def: { l2e_GetBasicInfo protocol = new l2e_GetBasicInfo(); protocol.FromBytes(data); } break; case ProtocolDef.l2e_Who_def: { l2e_Who protocol = new l2e_Who(); protocol.FromBytes(data); UpdatePlayerWho(protocol.PlayerList); } break; case ProtocolDef.l2e_GetGlobalVariable_def: { l2e_GetGlobalVariable protocol = new l2e_GetGlobalVariable(); protocol.FromBytes(data); server.GameSetting.UpdateGlobalVariable(protocol.VariableIndex, protocol.VariableValue); } break; case ProtocolDef.l2e_GetGameStartTime_def: { l2e_GetGameStartTime protocol = new l2e_GetGameStartTime(); protocol.FromBytes(data); int seconds = int.Parse(protocol.GameStartTime); _gameRunningRefreshTime = DateTime.Now; _gameRunningTime = new TimeSpan(0, 0, seconds); } break; case ProtocolDef.l2e_ReportError_def: { l2e_ReportError protocol = new l2e_ReportError(); protocol.FromBytes(data); SetModuleStateCode(protocol.Module, protocol.ErrorCode); } break; case ProtocolDef.l2e_info_def: { l2e_info protocol = new l2e_info(); protocol.FromBytes(data); Hashtable infoPackage = Util.ConvertKeyValuePairToHashtable(protocol.Info); if (infoPackage != null) GameInfoReceived(infoPackage); } break; case ProtocolDef.l2e_info_large_def: { l2e_info_large protocol = new l2e_info_large(); protocol.FromBytes(data); Hashtable infoPackage = Util.ConvertKeyValuePairToHashtable(protocol.InfoLarge); if (infoPackage != null) GameInfoReceived(infoPackage); } break; } }
private void MessageReceived(GameServer server, IProtocol message) { ISubProtocol pSubProtocol = message.GetSubProtocol(); if (pSubProtocol == null || (ProtocolDef)message.ProtocolId != ProtocolDef.l2e_header_def) { return; } byte[] data = message.ToBytes(); switch ((ProtocolDef)pSubProtocol.SubProtocolID) { // ahpho case ProtocolDef.l2e_update_custom_info_def: { l2e_update_custom_info protocal = new l2e_update_custom_info(); protocal.FromBytes(data); _customInfoStrs = protocal.GetInfoStrs(); } break; case ProtocolDef.l2e_PlayerCount_def: { l2e_PlayerCount protocol = new l2e_PlayerCount(); protocol.FromBytes(data); if (protocol.GetTotalCount() >= 0) { UpdatePlayerCount(protocol.GetTotalCount(), server.Group); } if (protocol.GetOffliveCount() >= 0) { UpdateOfflineCount(protocol.GetOffliveCount()); } } break; //GM指令接收的消息 case ProtocolDef.l2e_ExeGMCmd_def: { l2e_ExeGMCmd protocol = new l2e_ExeGMCmd(); protocol.FromBytes(data); //l2e_ExeGMCmd protocol = (l2e_ExeGMCmd)message; if (protocol.ReturnCode == 1) { UpdateGMResultCache(protocol.nSessionID, protocol.szResult); } else { UpdateGMResultCache(protocol.nSessionID, "GM指令操作失败"); } } break; case ProtocolDef.l2e_GetBasicInfo_def: { l2e_GetBasicInfo protocol = new l2e_GetBasicInfo(); protocol.FromBytes(data); } break; case ProtocolDef.l2e_Who_def: { l2e_Who protocol = new l2e_Who(); protocol.FromBytes(data); UpdatePlayerWho(protocol.PlayerList); } break; case ProtocolDef.l2e_GetGlobalVariable_def: { l2e_GetGlobalVariable protocol = new l2e_GetGlobalVariable(); protocol.FromBytes(data); server.GameSetting.UpdateGlobalVariable(protocol.VariableIndex, protocol.VariableValue); } break; case ProtocolDef.l2e_GetGameStartTime_def: { l2e_GetGameStartTime protocol = new l2e_GetGameStartTime(); protocol.FromBytes(data); int seconds = int.Parse(protocol.GameStartTime); _gameRunningRefreshTime = DateTime.Now; _gameRunningTime = new TimeSpan(0, 0, seconds); } break; case ProtocolDef.l2e_ReportError_def: { l2e_ReportError protocol = new l2e_ReportError(); protocol.FromBytes(data); SetModuleStateCode(protocol.Module, protocol.ErrorCode); } break; case ProtocolDef.l2e_info_def: { l2e_info protocol = new l2e_info(); protocol.FromBytes(data); Hashtable infoPackage = Util.ConvertKeyValuePairToHashtable(protocol.Info); if (infoPackage != null) { GameInfoReceived(infoPackage); } } break; case ProtocolDef.l2e_info_large_def: { l2e_info_large protocol = new l2e_info_large(); protocol.FromBytes(data); Hashtable infoPackage = Util.ConvertKeyValuePairToHashtable(protocol.InfoLarge); if (infoPackage != null) { GameInfoReceived(infoPackage); } } break; } }