コード例 #1
0
        public void RemoveListenEvent <T>(NetCallBackMethod <T> callBack) where T : class
        {
            Type  typeFromHandle  = typeof(T);
            short recvPacketsType = NetworkUtility.GetRecvPacketsType(typeFromHandle);

            if (!NetworkService.receivePacketHandler.ContainsKey(recvPacketsType))
            {
                return;
            }
            List <NetHandler> list = NetworkService.receivePacketHandler.get_Item(recvPacketsType);

            for (int i = 0; i < list.get_Count(); i++)
            {
                if (list.get_Item(i).Method == callBack.get_Method() && list.get_Item(i).Target == callBack.get_Target())
                {
                    list.Remove(list.get_Item(i));
                    return;
                }
            }
        }
コード例 #2
0
        public void AddListenEvent <T>(NetCallBackMethod <T> callBack) where T : class
        {
            Type  typeFromHandle  = typeof(T);
            short recvPacketsType = NetworkUtility.GetRecvPacketsType(typeFromHandle);

            if (!NetworkService.receivePacketHandler.ContainsKey(recvPacketsType))
            {
                NetworkService.receivePacketHandler.Add(recvPacketsType, new List <NetHandler>());
            }
            NetworkService.receivePacketHandler.get_Item(recvPacketsType).Add(new NetHandler(callBack.get_Method(), callBack.get_Target()));
        }