public void Run(ETModel.Session s, ushort opcode, MemoryStream memoryStream) { OpcodeTypeComponent opcodeTypeComponent = Game.Scene.GetComponent <OpcodeTypeComponent>(); object instance = opcodeTypeComponent.GetInstance(opcode); object message = this.session.Network.MessagePacker.DeserializeFrom(instance, memoryStream); if (OpcodeHelper.IsNeedDebugLogMessage(opcode)) { Log.Msg(message); } IResponse response = message as IResponse; if (response == null) { Game.Scene.GetComponent <MessageDispatcherComponent>().Handle(session, new MessageInfo(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); }
public void Run(ETModel.Session s, byte flag, ushort opcode, MemoryStream memoryStream) { OpcodeTypeComponent opcodeTypeComponent = Game.Scene.GetComponent <OpcodeTypeComponent>(); object instance = opcodeTypeComponent.GetInstance(opcode); object message = this.session.Network.MessagePacker.DeserializeFrom(instance, memoryStream); if (OpcodeHelper.IsNeedDebugLogMessage(opcode)) { Log.Msg(message); } if ((flag & 0x01) > 0) { IResponse response = message as IResponse; if (response == null) { throw new Exception($"flag is response, but hotfix message is not! {opcode}"); } Action <IResponse> action; if (!this.requestCallback.TryGetValue(response.RpcId, out action)) { return; } this.requestCallback.Remove(response.RpcId); action(response); return; } Game.Scene.GetComponent <MessageDispatherComponent>().Handle(session, new MessageInfo(opcode, message)); }
public void Send(ushort opcode, IMessage message) { if (OpcodeHelper.IsNeedDebugLogMessage(opcode)) { Log.Msg(message); } session.Send(opcode, message); }
public void Send(byte flag, ushort opcode, IMessage message) { session.Send(flag, opcode, message); if (OpcodeHelper.IsNeedDebugLogMessage(opcode)) { ETModel.Log.Msg(message); } }
public void Run(ETModel.Session s, ushort opcode, MemoryStream memoryStream) { OpcodeTypeComponent opcodeTypeComponent = Game.Scene.GetComponent <OpcodeTypeComponent>(); object instance = opcodeTypeComponent.GetInstance(opcode); object message = this.session.Network.MessagePacker.DeserializeFrom(instance, memoryStream); //屏蔽心跳日志输出 10009,和广播玩家下注日志 10044 && opcode!= 10044 if (OpcodeHelper.IsNeedDebugLogMessage(opcode) && opcode != 10009 && opcode != 10044) { Log.Msg(message, 1); } IResponse response = message as IResponse; //临时解决斗地主,没法收到消息的问题 if (response != null && response.Error == 200225) { Game.EventSystem.Run(EventIdType.DDZOutCardError, response.Message); } if (response == null) { Game.Scene.GetComponent <MessageDispatcherComponent>().Handle(session, new MessageInfo(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); }