Esempio n. 1
0
        public void RemovePublisher_Success()
        {
            var        container = new TopicContainer();
            IPublisher pub;

            container.HasPublisher("pub1").Is(false);
            container.GetPublishers().Count.Is(0);

            container.AddPublisher(new Publisher <std_msgs.String>("pub1", "test")).Is(true);
            container.HasPublisher("pub1").Is(true);
            container.GetPublishers().Count.Is(1);
            container.GetPublisher("pub1", out pub).Is(true);

            container.RemovePublisher("pub1").Is(true);
            container.GetPublisher("pub1", out pub).Is(false);

            container.RemovePublisher("pub1").Is(false);
        }
Esempio n. 2
0
        private Task DisposePublisherAsync(string topicName)
        {
            _logger.Debug(m => m("Disposing Publisher[{0}]", topicName));

            return(_masterClient
                   .UnregisterPublisherAsync(NodeId, topicName, _slaveServer.SlaveUri)
                   .ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    _logger.Error("UnregisterPublisher: Failure", task.Exception.InnerException);
                }
                _topicContainer.RemovePublisher(topicName);
                _slaveServer.RemoveListener(topicName);

                _publisherDisposables[topicName].Dispose();
                _publisherDisposables.Remove(topicName);
                _logger.Debug(m => m("UnregisterPublisher: [{0}]", topicName));
            }));
        }