void OnReceiveMessage(MsgType type, byte[] data) { this.Log($"receive response : {type}"); Type t = MsgTypeMap.GeType(type); IMessage message = Activator.CreateInstance(t) as IMessage; message.MergeFrom(data); mMessages.Enqueue(new KeyValuePair <MsgType, IMessage>(type, message)); }
public void HandleRequest(MsgType type, byte[] data, Client client) { Type t = MsgTypeMap.GeType(type); IMessage message = Activator.CreateInstance(t) as IMessage; message.MergeFrom(data); Console.WriteLine("接收到客户端请求 " + type); GetMsgCallBack(type).Invoke(message, client); }