//------------//[MyAppend end]------------ private void Run(MemoryStream memoryStream) { memoryStream.Seek(Packet.MessageIndex, SeekOrigin.Begin); ushort opcode = BitConverter.ToUInt16(memoryStream.GetBuffer(), Packet.OpcodeIndex); //------------//[MyAppend begin]------------ if (!checkOpcode(opcode)) { myDebug(opcode); this.Error = ErrorCode.ERR_PacketParserError; this.Network.Remove(this.Id); return; } //------------//[MyAppend end]------------ #if !SERVER if (OpcodeHelper.IsClientHotfixMessage(opcode)) { this.GetComponent <SessionCallbackComponent>().MessageCallback.Invoke(this, opcode, memoryStream); return; } #endif object message; try { OpcodeTypeComponent opcodeTypeComponent = this.Network.Entity.GetComponent <OpcodeTypeComponent>(); object instance = opcodeTypeComponent.GetInstance(opcode); message = this.Network.MessagePacker.DeserializeFrom(instance, memoryStream); } catch (Exception e) { // 出现任何消息解析异常都要断开Session,防止客户端伪造消息 // Log.Error($"opcode: {opcode} {this.Network.Count} {e} " + myDebug(memoryStream)); //Log.Error(e + ", opcode: " + opcode + ", this.Network.Count: " + this.Network.Count + ", " + myDebug(memoryStream)); this.Error = ErrorCode.ERR_PacketParserError; this.Network.Remove(this.Id); return; } IResponse response = message as IResponse; if (response == null) { //屏蔽心跳日志输出 10008 //屏蔽广播玩家下注日志 10050 //屏蔽广播推送的消息 request //1011数据存储 if (OpcodeHelper.IsNeedDebugLogMessage(opcode) && opcode != 10008 && opcode != 10050 && opcode != 1011 && opcode != 1012 && opcode != 1009 && opcode != 1010 && (message as IActorMessage) == null ) { Log.Msg(message); } this.Network.MessageDispatcher.Dispatch(this, opcode, message); return; } Action <IResponse> action; if (!this.requestCallback.TryGetValue(response.RpcId, out action)) { throw new Exception($"not found rpc, response message: {StringHelper.MessageToStr(response)}"); } this.requestCallback.Remove(response.RpcId); action(response); //屏蔽心跳日志输出 10008 //屏蔽广播玩家下注日志 10050 if (OpcodeHelper.IsNeedDebugLogMessage(opcode) && opcode != 10008 && opcode != 10050 && opcode != 1011 && opcode != 1012 && opcode != 1010 && opcode != 1009) { Log.Msg(message); } }