Example #1
0
        /**
         * 设置某个action不销毁
         */
        public void setActionForever(Api.ENetMsgId id)
        {
            if (!msgMap.ContainsKey(id))
            {
                Debug.LogError("register handler of " + id + " first");
            }

            msgMap[id].isOnce = false;
        }
Example #2
0
        public bool RegisterAction(Api.ENetMsgId id, System.Action <object> act)
        {
            if (!msgMap.ContainsKey(id))
            {
                Debug.LogError("register handler of " + id + " first");
                return(false);
            }

            msgMap[id].action = act;

            return(true);
        }
Example #3
0
        public bool RegisterHandler(Api.ENetMsgId id, MsgHandler handler)
        {
            if (msgMap.ContainsKey(id))
            {
                Debug.LogError(id + " is already registered");
                return(false);
            }
            Group g = new Group();

            g.handler = new MsgHandler(handler);
            g.action  = null;
            msgMap.Add(id, g);

            return(true);
        }
Example #4
0
        public bool InvokeHandler(Api.ENetMsgId id, byte[] data)
        {
            if (!msgMap.ContainsKey(id))
            {
                Debug.LogError(id + " is not registered");
                return(false);
            }

            Group g = msgMap[id];

            object ret = g.handler(data);

            if (g.action != null)
            {
                g.action.Invoke(ret);
                g.action = null;
            }

            return(true);
        }