Beispiel #1
0
        public List <RegistrationInfo> RegisterSubscriber(string nodeId, string topic, string topicType, Uri slaveUri)
        {
            TopicRegistrationInfo info;

            if (_topicRegistrationInfos.ContainsKey(topic))
            {
                info = _topicRegistrationInfos[topic];
            }
            else
            {
                info = new TopicRegistrationInfo()
                {
                    TopicName = topic,
                    TopicType = topicType
                };
                _topicRegistrationInfos.Add(topic, info);
            }

            if (!info.Subscribers.Any(x => x.NodeId == nodeId && x.Uri == slaveUri))
            {
                info.Subscribers.Add(new RegistrationInfo()
                {
                    NodeId = nodeId, Uri = slaveUri
                });
            }

            return(info.Publishers);
        }
        private void UpdatePublisher(string callerId, TopicRegistrationInfo info)
        {
            var slaves = info.Subscribers.Select(x => new SlaveClient(x.Uri));

            var publishers = info.Publishers.Select(x => x.Uri.ToString()).ToArray();

            _logger.Debug(m => m("UpdatePublisher: slaves={0}, publishers={1}", slaves.Count(), publishers.Length));

            foreach (var slave in slaves)
            {
                slave.PublisherUpdateAsync(callerId, info.TopicName, publishers)
                .ContinueWith(task =>
                {
                    _logger.Error("UpdatePublisher: Failure", task.Exception.InnerException);
                }, TaskContinuationOptions.OnlyOnFaulted);
            }
        }
        public TopicRegistrationInfo RegisterPublisher(string nodeId, string topic, string topicType, Uri slaveUri)
        {
            TopicRegistrationInfo info;
            if (_topicRegistrationInfos.ContainsKey(topic))
            {
                info = _topicRegistrationInfos[topic];
            }
            else
            {
                info = new TopicRegistrationInfo()
                {
                    TopicName = topic,
                    TopicType = topicType
                };
                _topicRegistrationInfos.Add(topic, info);
            }

            if (!info.Publishers.Any(x => x.NodeId == nodeId && x.Uri == slaveUri))
            {
                info.Publishers.Add(new RegistrationInfo() { NodeId = nodeId, Uri = slaveUri });
            }

            return info;
        }
Beispiel #4
0
        private void UpdatePublisher(string callerId, TopicRegistrationInfo info)
        {
            var slaves = info.Subscribers.Select(x => new SlaveClient(x.Uri));

            var publishers = info.Publishers.Select(x => x.Uri.ToString()).ToArray();

            _logger.Debug(m => m("UpdatePublisher: slaves={0}, publishers={1}", slaves.Count(), publishers.Length));

            foreach (var slave in slaves)
            {
                slave.PublisherUpdateAsync(callerId, info.TopicName, publishers)
                    .ContinueWith(task =>
                    {
                        _logger.Error("UpdatePublisher: Failure", task.Exception.InnerException);
                    }, TaskContinuationOptions.OnlyOnFaulted);
            }
        }