Пример #1
0
 public static void InsertEventToRecyclingPool(MSGEvent e)
 {
     lock (recyclingPoolLock)
     {
         eventRecyclingPool.Enqueue(e);
     }
 }
Пример #2
0
        private void EnqueueEvent(InitEventFuc initFuc)
        {
            MSGEvent e = NewOrDequeueFromPoolNetEvent();

            initFuc(e);
            queue.Enqueue(e);
            logger.d("Event Logged =>" + e.EventType.ToString());
        }
Пример #3
0
    void Update()
    {
        MSG.MSGEvent e = null;
        PlayerPrefs.SetString("m_MSG_LogLevel", m_MSG_LogLevel.ToString());

        m_discon_uid_list.Clear();
        foreach (var v in m_mapMSGClient)
        {
            nNWM.nDummy.NetEventPlugin plugin = v.Value;
            MSG.MSGClient client = plugin.m_MSGClient;
            if (client == null)
            {
                continue;
            }

            while (client.PopEvent(out e))
            {
                switch (e.EventType)
                {
                case MSG.MSGEventType.Connected:
                    plugin.NetLog("[Net] On Connect : " + plugin.db_id(), true);                            //nNWM.nUtil.jDumper.NamedDump(e));
                    plugin.OnConnect();
                    break;

                case MSG.MSGEventType.Disconnected:
                    plugin.NetLog("[Net] On Disconnect", true);                           // + nNWM.nUtil.jDumper.NamedDump(e),true);
                    plugin.OnDisconnect();
                    plugin.m_MSGClient = null;
                    //m_discon_uid_list.Add(plugin.db_id());
                    break;

                case MSG.MSGEventType.RecvMessage:
                    onRecvFromUG(plugin, e);
                    break;

                default:
                    plugin.NetError("[Net] Unkown MSGEventType : " + e.EventType.ToString() + " : " + nNWM.nUtil.jDumper.NamedDump(e));
                    break;
                }
            }
            if (e != null)
            {
                client.InsertEventToRecyclingPool(e);
            }
        }        //foreach (var v in m_mapMSGClient)

//      foreach(var uid in m_discon_uid_list)
//      {
//          m_mapMSGClient.Remove(uid);
//      }
    }    //void FixedUpdate ()
Пример #4
0
    }    //void FixedUpdate ()

    //#--------------------------------------------------------------------------
    // private member function
    //#--------------------------------------------------------------------------

    void onRecvFromUG(nNWM.nDummy.NetEventPlugin plugin, MSG.MSGEvent e)
    {
        MSG.AnswerMessage ans = e.RecvMessage;

        switch (ans.Type)
        {
        case MSG.AnswerMessage.AnsType.Connect:
            //status = Status.Login;
            plugin.NetLog("[Recv:MSG] AnsConnect (Login Succeed)=>" + nNWM.nUtil.jDumper.NamedDump(ans.Connect, m_PacketLogType), true);
            plugin.OnRecv_FromMSG(ans.Connect);
            break;

        case MSG.AnswerMessage.AnsType.Info:
            plugin.NetLog("[Recv:MSG] AnsGameInfo  ", true);                   // + System.BitConverter.ToString(ans.Info.GameInfo), true);
            plugin.OnRecv_FromMSG(ans.Info);
            break;

        case MSG.AnswerMessage.AnsType.Channel:
            plugin.NetLog("[Recv:MSG] AnsChannel", true);
            plugin.OnRecv_FromMSG(ans.Channel);
            break;

        case MSG.AnswerMessage.AnsType.AutoJoin:
            plugin.NetLog("[Recv:MSG] AnsAutoJoin ", true);
            plugin.OnRecv_FromMSG(ans.AutoJoin);
            break;

        case MSG.AnswerMessage.AnsType.LeaveGame:
            plugin.NetLog("[Recv:MSG] AnsLeaveGame", true);
            //plugin.m_CMD.Log(nNWM.nUtil.jDumper.NamedDump(ans.LeaveGame));
            plugin.OnRecv_FromMSG(ans.LeaveGame);
            break;

        case MSG.AnswerMessage.AnsType.Close:
            plugin.NetLog("[Recv:MSG] AnsClose ", true);
            plugin.m_CMD.Log(nNWM.nUtil.jDumper.NamedDump(ans.Close));
            plugin.OnRecv_FromMSG(ans.Close);
            break;

        case MSG.AnswerMessage.AnsType.Notice:
            plugin.NetLog("[Recv:MSG] AnsNotice =>" + nNWM.nUtil.jDumper.NamedDump(ans.Notice.Notices, m_PacketLogType), true);
            plugin.OnRecv_FromMSG(ans.Notice);
            break;

        case MSG.AnswerMessage.AnsType.DB:
            plugin.OnRecv_FromMSG(ans.DB);
            break;

        case MSG.AnswerMessage.AnsType.GameProtocol:
            //status = Status.InGame;
            //plugin.NetLog("[Recv:MSG] GameProtocol", true);
            //plugin.Log("Message => " + BitConverter.ToString(ans.GameProtocol.Buffer));
            plugin.OnRecv_FromGameServer(ans.GameProtocol.Buffer);
            break;

        case MSG.AnswerMessage.AnsType.Error:
            plugin.NetError("[Recv:MSG] AnsError =>" + nNWM.nUtil.jDumper.NamedDump(ans.Error, nNWM.nUtil.jDumper.EDumpType.eALL));
            plugin.OnRecv_FromMSG(ans.Error);
            break;

        default:
            plugin.NetError("[Recv:MSG] Unkown AnswerMessage =>" + nNWM.nUtil.jDumper.NamedDump(ans));
            plugin.OnRecv_Unkown(ans);
            break;
        }
    }    //void onRecvFromUG(MSGEvent e)