Exemple #1
0
    public NetworkMgr()
    {
        this.msgQueue = new Queue <JsonObject>();

        //把回调的key和托管函数 对应起来
        CallbackFact.registCallbacks();
        BroadcastFact.registEvents();
    }
Exemple #2
0
    //扫描消息队列,看是否有数据要处理
    public void update()
    {
        while (this.msgQueue.Count > 0)
        {
            JsonObject data  = this.msgQueue.Dequeue();
            string     route = data[CallbackFact.ROUTE_KEY_NAME] as string;
            if (route == null)
            {
                Debug.LogError("cannt find route in msg");
            }
            //调用回调函数

            if (!data.ContainsKey(BroadcastFact.IS_EVT_KEY_NAME))
            {//不是广播
                CallbackFact.invokeHandle(route, data);
            }
            else
            {
                BroadcastFact.invokeHandle(route, data);
            }
        }
    }