예제 #1
0
        private void OnDestroy()
        {
            OnBeforeDestroy();
            foreach (var msgRecord in _mMsgRecorder)
            {
                MsgDispatcher.UnRegister(msgRecord.Name, msgRecord.OnMsgReceived);
                msgRecord.Recycle();
            }

            _mMsgRecorder.Clear();
        }
예제 #2
0
        private static void MenuClicked()
        {
            MsgDispatcher.UnRegisterAll("消息1");

            MsgDispatcher.Register("消息1", OnMsgReceived);
            MsgDispatcher.Register("消息1", OnMsgReceived);

            MsgDispatcher.Send("消息1", "hello world");
            MsgDispatcher.UnRegister("消息1", OnMsgReceived);
            MsgDispatcher.Send("消息1", "hello");
        }
예제 #3
0
        public void UnRegisterMsg(string msgName)
        {
            var selectedRecords = _mMsgRecorder.FindAll(record => record.Name == msgName);

            selectedRecords.ForEach(record =>
            {
                MsgDispatcher.UnRegister(record.Name, record.OnMsgReceived);
                _mMsgRecorder.Remove(record);
                record.Recycle();
            });

            selectedRecords.Clear();
        }