public void AddNetMsgProcessor(GameMsgType nMsgType, NetMsgProcessor Porcessor) { m_ProcessorList.Add(new NetMsgProcessorPair(nMsgType, Porcessor)); if (m_bEnable) { NetMsgMap.RegistMsgProcessor(nMsgType, Porcessor); } }
public static void AddProductLine(CreateMsg cm, GameMsgType nType) { if (s_MsgObjMap.ContainsKey(nType)) { Debug.LogError("register repeat message create func, msg type: " + nType); } s_MsgObjMap[nType] = cm; }
public void doMyDecode(GameMsgType Type) { INetWorkMessage gamemsg = MsgFactory.CreateMsgByType(Type); if (gamemsg != null) { m_ReadMsgQueue.Enqueue(gamemsg); } }
private bool doDecode() { if (m_Readbuffer.remaining() > 1) { int pos = m_Readbuffer.getPostion(); int size = m_Readbuffer.GetUShort(); if (size >= 4 && size <= 65535) { if (size - 2 <= m_Readbuffer.remaining()) { GameMsgType Type = (GameMsgType)m_Readbuffer.GetUShort(); INetWorkMessage gamemsg = MsgFactory.CreateMsgByType(Type); if (gamemsg != null) { if (gamemsg.decodeMessage(m_Readbuffer)) { if (m_Readbuffer.getPostion() - pos != size) { Debug.LogError("handleXQMsg position error,Postion :" + m_Readbuffer.getPostion() + "," + pos + "," + size + ",ID:" + Type); m_Readbuffer.setMaxDataPostion(pos + size); m_Readbuffer.setPostion(pos + size); } else { m_ReadMsgQueue.Enqueue(gamemsg); } } else { Debug.LogError("Decode message failed, Type:" + Type + ",Size:" + size); //m_Readbuffer.Clear(); } } return(true); } else { m_Readbuffer.setPostion(pos); } } else { return(true); } } return(false); }
public static INetWorkMessage CreateMsgByType(GameMsgType nType) { if (s_MsgObjMap.ContainsKey(nType)) { CreateMsg cm = (CreateMsg)s_MsgObjMap[nType]; return(cm()); } else { Debug.LogError("register none message create func, msg type: " + nType); return(new GameMsgBase(nType)); } }
public static void RegistMsgProcessor(GameMsgType nMsgType, NetMsgProcessor Msgprocessor) { //Debug.Log("RegistMsgProcessor,nMsgType:" + nMsgType); if (s_MsgMap.Contains(nMsgType)) { NetMsgProcessor OldHandler = (NetMsgProcessor)s_MsgMap[nMsgType]; OldHandler += Msgprocessor; s_MsgMap[nMsgType] = OldHandler; } else { s_MsgMap[nMsgType] = Msgprocessor; } }
public static void UnRegistMsgProcessor(GameMsgType nMsgType, NetMsgProcessor Msgprocessor) { if (s_MsgMap.Contains(nMsgType)) { NetMsgProcessor OldHandler = (NetMsgProcessor)s_MsgMap[nMsgType]; OldHandler -= Msgprocessor; if (OldHandler != null) { s_MsgMap[nMsgType] = OldHandler; } else { s_MsgMap.Remove(nMsgType); } } }
public static void DispatchNetMsg(GameMsgBase Msg) { //Debug.Log("DispatchNetMsg Msg:" + Msg.getMsgType() + "s_MsgMap count" + s_MsgMap.Count); GameMsgType nMsgType = Msg.getMsgType(); if (s_MsgMap.Contains(nMsgType)) { //Debug.Log("DispatchNetMsg 2"); NetMsgProcessor MsgEntry = (NetMsgProcessor)s_MsgMap[nMsgType]; if (MsgEntry != null) { MsgEntry(Msg); } else { Debug.LogError("MsgEntry is null ,ID:" + Msg.getMsgType()); } } }
//public string m_strError = "" ; //public GameMsgBase() //{ //} public GameMsgBase(GameMsgType MsgType) { m_nMsgType = MsgType; }
public NetMsgProcessorPair(GameMsgType MsgType, NetMsgProcessor processor) { m_uMsgType = MsgType; m_processor = processor; }
public void setMsgType(GameMsgType value) { m_uMsgType = value; }
public static void DoMessage(GameMsgType Type) { mInstance.m_NetConn.doMyDecode(Type); }