Exemple #1
0
        void Execute(Message msg)
        {
            List <ActionMessage> excutors = null;

            if (!executorDic.TryGetValue(msg.messageID, out excutors))
            {
                callbackNotFoundMessage?.Invoke(msg.messageID);
                return;
            }

            removeExecutors.Clear();
            for (int i = 0; i < excutors.Count; i++)
            {
                var excutor = excutors[i];
                if (excutor.isVaild)
                {
                    excutor.executor(msg);
                }
                else
                {
                    removeExecutors.Add(excutor);
                }
            }
            msg.Release();

            for (int i = 0; i < removeExecutors.Count; i++)
            {
                excutors.Remove(removeExecutors[i]);
                ActionMessage.pool.Delete(removeExecutors[i]);
            }
        }
 static int Release(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UFrame.MessageCenter.Message obj = (UFrame.MessageCenter.Message)ToLua.CheckObject <UFrame.MessageCenter.Message>(L, 1);
         obj.Release();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #3
0
        void Execute(Message msg)
        {
            HashSet <Action <Message> > excutors = null;

            if (!executorDic.TryGetValue(msg.messageID, out excutors))
            {
                throw new System.Exception("消息未注册" + msg.messageID);
            }

            foreach (var executor in excutors)
            {
                executor(msg);
            }
            msg.Release();
        }
        public void Tick()
        {
            while (true)
            {
                if (messages.Count <= 0)
                {
                    return;
                }

                Message          msg      = messages.Dequeue();
                IMessageExecutor executor = null;
                if (executors.TryGetValue(msg.messageID, out executor))
                {
                    executor.Execute(msg);
                }
                msg.Release();
            }
        }
        public void Tick()
        {
            while (true)
            {
                if (messages.Count <= 0)
                {
                    return;
                }

                Message msg = messages.Dequeue();

                LinkedList <BroadcastMessageExecutor> linkExecutor = null;
                if (!executors.TryGetValue(msg.messageID, out linkExecutor))
                {
                    throw new System.Exception("没有消息被注册" + msg.messageID);
                }

                foreach (var executor in linkExecutor)
                {
                    executor.Execute(msg);
                }
                msg.Release();
            }
        }