Example #1
0
 public MQTopicCallBack(MQTopic aTopic, TopicSubscribeCallBack aTopicSubscribeCallBack)
 {
     _topic = aTopic;
     _topicSubscribeCallBack = aTopicSubscribeCallBack;
 }
Example #2
0
        /// <summary>
        /// ע�ᶩ������
        /// </summary>
        /// <param name="aTopic">����</param>
        /// <param name="aTopicSubscribeCallBack">���ⶩ�Ļص�����</param>
        public void RegisterTopic(MQTopic aTopic, TopicSubscribeCallBack aTopicSubscribeCallBack)
        {
            if (String.IsNullOrEmpty(aTopic.TopicName))
                return;

            MQTopicCallBack mqTopicCallBack = null;

            lock (_callbackDict)
            {
                if (_callbackDict.ContainsKey(aTopic.TopicName))
                    return;

                mqTopicCallBack = new MQTopicCallBack(aTopic, aTopicSubscribeCallBack);
                _callbackDict.Add(aTopic.TopicName, mqTopicCallBack);
            }

            if (mqTopicCallBack != null)
            {
                RegisterMessageListener(String.Format("topic://{0}", aTopic.TopicName), mqTopicCallBack.OnMessageListener, String.Empty);
            }
        }
Example #3
0
        /// <summary>
        /// ȡ����������
        /// </summary>
        /// <param name="aTopic">����</param>
        public void UnRegisterTopic(MQTopic aTopic)
        {
            lock (_callbackDict)
            {
                _callbackDict.Remove(aTopic.TopicName);
            }

            // ʹ�ÿ���ȡ��ͬ��/�첽�µĶ���
            UnConsume(String.Format("topic://{0}", aTopic.TopicName), String.Empty);
        }
Example #4
0
 /// <summary>
 /// �ж������Ƿ��Ѿ�ע��
 /// </summary>
 /// <param name="topic">����</param>
 /// <returns>���</returns>
 public bool IsRegistered(MQTopic topic)
 {
     lock (_callbackDict)
     {
         return _callbackDict.ContainsKey(topic.TopicName);
     }
 }