public void Run(Session s, Packet p) { ushort opcode = p.Opcode(); byte flag = p.Flag(); OpcodeTypeComponent opcodeTypeComponent = Game.Scene.GetComponent <OpcodeTypeComponent>(); Type responseType = opcodeTypeComponent.GetType(opcode); object message = ProtobufHelper.FromBytes(responseType, p.Bytes, Packet.Index, p.Length - Packet.Index); 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 T DeserializeFrom <T>(byte[] bytes, int index, int count) { return(ProtobufHelper.FromBytes <T>(bytes, index, count)); }
public T DeserializeFrom <T>(byte[] bytes) { return(ProtobufHelper.FromBytes <T>(bytes)); }
public object DeserializeFrom(Type type, byte[] bytes, int index, int count) { return(ProtobufHelper.FromBytes(type, bytes, index, count)); }
public object DeserializeFrom(Type type, byte[] bytes) { return(ProtobufHelper.FromBytes(type, bytes)); }
public object DeserializeFrom(object instance, byte[] bytes, int index, int count) { return(ProtobufHelper.FromBytes(instance, bytes, index, count)); }