Пример #1
0
 public void AddNetMsgProcessor(GameMsgType nMsgType, NetMsgProcessor Porcessor)
 {
     m_ProcessorList.Add(new NetMsgProcessorPair(nMsgType, Porcessor));
     if (m_bEnable)
     {
         NetMsgMap.RegistMsgProcessor(nMsgType, Porcessor);
     }
 }
Пример #2
0
        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;
        }
Пример #3
0
        public void doMyDecode(GameMsgType Type)
        {
            INetWorkMessage gamemsg = MsgFactory.CreateMsgByType(Type);

            if (gamemsg != null)
            {
                m_ReadMsgQueue.Enqueue(gamemsg);
            }
        }
Пример #4
0
        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);
        }
Пример #5
0
 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));
     }
 }
Пример #6
0
 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;
     }
 }
Пример #7
0
 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);
         }
     }
 }
Пример #8
0
        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());
                }
            }
        }
Пример #9
0
        //public string m_strError = "" ;
        //public GameMsgBase()
        //{

        //}
        public GameMsgBase(GameMsgType MsgType)
        {
            m_nMsgType = MsgType;
        }
Пример #10
0
 public NetMsgProcessorPair(GameMsgType MsgType, NetMsgProcessor processor)
 {
     m_uMsgType  = MsgType;
     m_processor = processor;
 }
Пример #11
0
 public void setMsgType(GameMsgType value)
 {
     m_uMsgType = value;
 }
Пример #12
0
 public static void DoMessage(GameMsgType Type)
 {
     mInstance.m_NetConn.doMyDecode(Type);
 }