コード例 #1
0
        public void BoardCastEvent(IEvent evt)
        {
            if (evt == null)
            {
                TLogger.WarningInfo("evt==null :", "EventCenter", "BoardCastEvent");
                return;
            }
            int evtType = evt.EventType;

            ///永久性事件优先处理
            if (this.eventHandlersPermanently.ContainsKey(evtType))
            {
                this.eventHandlersPermanently[evtType].BoardcastEvent(evt);
            }

            if (!this.eventHandlers.ContainsKey(evtType))
            {
                TLogger.WarningInfo("eventHandlers not contain event process :" + evt.ToSring(), "EventCenter",
                                    "BoardCastEvent");
                evt.DestroySelf();
                return;
            }

            this.eventHandlers[evtType].BoardcastEvent(evt);
            evt.DestroySelf();
        }
コード例 #2
0
        /// <summary>
        ///  处理永久性事件,其他事件不处理
        /// </summary>
        public void ProcessAndFilter()
        {
            while (eventQueue.Count > 0)
            {
                IEvent evt = eventQueue.Dequeue();
                if (eventHandlersPermanently.ContainsKey(evt.EventType))
                {
                    BoardCastEvent(evt);
                }

                evt.DestroySelf();
            }
        }