Example #1
0
        /// <inheritdoc />
        public Task PublishAsync(PublishedMessage message, CancellationToken cancel)
        {
            if (tracker.RecentlySeen(message.MessageId))
                return Task.CompletedTask;

            // Find a set of peers that are interested in the topic(s).
            // Exclude author and sender
            var peers = message.Topics
                .SelectMany(topic => RemoteTopics.GetPeers(topic))
                .Where(peer => peer != message.Sender)
                .Where(peer => peer != message.Forwarder);

            // Forward the message.
            var forward = new PubSubMessage
            {
                PublishedMessages = new PublishedMessage[] { message }
            };

            return SendAsync(forward, peers, cancel);
        }
Example #2
0
 /// <inheritdoc />
 public IEnumerable<Peer> InterestedPeers(string topic)
 {
     return RemoteTopics.GetPeers(topic);
 }