Example #1
0
File: B.cs Project: diviner69/U3D
 void OnDestroy()
 {
     OnBeforeDestroy();
     foreach (var msgRecord in mMsgRecords)
     {
         MsgDispatcher.UnRegister(msgRecord.Name, msgRecord.OnMysgReceived);
         msgRecord.Recycle();
     }
 }
        private static void MenuClicked()
        {
            MsgDispatcher.UnRegisterAll("Message_1");
            MsgDispatcher.Register("Message_1", OnMsgReceived);
            MsgDispatcher.Register("Message_1", OnMsgReceived);

            MsgDispatcher.Send("Message_1", "hello world");

            MsgDispatcher.UnRegister("Message_1", OnMsgReceived);
            MsgDispatcher.Send("Message_1", "hello");
        }
        protected void UnRegisterMsg(string msgName)
        {
            var selectedRecords = mMsgRecorder.FindAll(recorder => recorder.Name == msgName);

            selectedRecords.ForEach(selectRecord =>
            {
                MsgDispatcher.UnRegister(selectRecord.Name, selectRecord.OnMsgReceived);
                mMsgRecorder.Remove(selectRecord);
            });

            selectedRecords.Clear();
        }
        private void OnDestroy()
        {
            OnBeforeDestroy();

            foreach (var msgRecord in mMsgRecorder)
            {
                MsgDispatcher.UnRegister(msgRecord.Name, msgRecord.OnMsgReceived);
                msgRecord.Recycle();
            }

            mMsgRecorder.Clear();
        }
Example #5
0
        public void UnRegisterMsg(string msgName)
        {
            var selectedRecords =
                mMsgRecords.FindAll(record => record.Name == msgName);

            selectedRecords.ForEach(record =>
            {
                MsgDispatcher.UnRegister(record.Name, record.OnMysgReceived);
                mMsgRecords.Remove(record);
                record.Recycle();
            });
            selectedRecords.Clear();
        }
Example #6
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");
        }
        protected void UnRegisterMsg(string msgName, Action <object> onMsgRecevived)
        {
            var selectedRecords = m_MsgRegisterRecorder.FindAll(recorder =>
                                                                recorder.MsgName == msgName &&
                                                                recorder.OnMsgReceived == onMsgRecevived);

            selectedRecords.ForEach(selectedRecord =>
            {
                MsgDispatcher.UnRegister(selectedRecord.MsgName, selectedRecord.OnMsgReceived);
                m_MsgRegisterRecorder.Remove(selectedRecord);
            });

            selectedRecords.Clear();
        }