//解码 protected override NetCommand DecodeCmd(uint pid, MemoryStream payloadStream) { NetCommand cmd = null; // 根据pid找到对应的消息对象 var msgType = Registry.Find((uint)pid); if (msgType == null) { cmd = new ByteNetCommand { pid = (uint)pid, buf = payloadStream.ToArray() }; } else { cmd = ProtoBuf.Serializer.Deserialize(msgType, payloadStream) as NetCommand; } return(cmd); }
///------------------------------------------------------------------------------------ public static void AddEvent(int _event, ByteNetCommand data) { lock (m_lockObject) { mEvents.Enqueue(new KeyValuePair <int, ByteNetCommand>(_event, data)); } }