// 反序列化 public static object Deserialize(eMsgTypes type, byte[] data, int index, int length) { if (g_TypeDict.ContainsKey(type) == false) { UnityEngine.Debug.Log("客户端不存在该proto协议类型:" + type.ToString()); return(null); } Type t = g_TypeDict[type]; if (null == t) { UnityEngine.Debug.Log("客户端不存在该proto协议类型:" + type.ToString()); return(null); } g_ms.SetLength(0); g_ms.Write(data, index, length); g_ms.Seek(0, SeekOrigin.Begin); return(ProtoBuf.Meta.RuntimeTypeModel.Default.Deserialize(g_ms, null, t)); }
override public string ToString() { m_sbMsg.Length = 0; m_sbMsg.AppendFormat("<{0}>", eMsgTags.Msg.ToString()); m_sbMsg.AppendFormat("<{0}>{1}</{0}>", eMsgTags.MsgType.ToString(), m_eMsgType.ToString()); m_sbMsg.AppendFormat("<{0}>{1}</{0}>", eMsgTags.SeqNum.ToString(), m_iSeqNum.ToString()); m_sbMsg.AppendFormat("<{0}>{1}</{0}>", eMsgTags.DataSize.ToString(), m_iDataSize.ToString()); m_sbMsg.AppendFormat("<{0}>{1}</{0}>", eMsgTags.Data.ToString(), m_sData); m_sbMsg.AppendFormat("</{0}>", eMsgTags.Msg.ToString()); return(m_sbMsg.ToString()); } // ToString