Esempio n. 1
0
        /// <summary>
        /// 订阅主题
        /// </summary>
        /// <param name="topicName"></param>
        public void Subscribe(string topicName)
        {
            ICommand command = new SubscriberCommand();
            command.TopicName = topicName;
            _client.SendTo(SerializeHelper.ObjectToBytes(command), _remoteEndPoint);

            if (_isReceivingStarted == false)
            {
                _isReceivingStarted = true;
                _data = new byte[1024];
                Thread thread1 = new Thread(new ThreadStart(ReceiveDataFromServer));
                thread1.IsBackground = true;
                thread1.Start();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 订阅主题 异常信息[ConnectException] 尚未建立建立
        /// </summary>
        /// <param name="topicName"></param>
        public void Subscribe(string topicName)
        {
            ICommand command = new SubscriberCommand();
            command.TopicName = topicName;
            Send(SerializeHelper.ObjectToBytes(command));

            if (_isReceivingStarted == false)
            {
                _isReceivingStarted = true;
                Thread thread1 = new Thread(new ThreadStart(ReceiveDataFromServer));
                thread1.IsBackground = true;
                thread1.Start();
            }
        }