-
Notifications
You must be signed in to change notification settings - Fork 16
/
IMessageRouter.cs
76 lines (70 loc) · 2.53 KB
/
IMessageRouter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using Ipfs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace PeerTalk.PubSub
{
/// <summary>
/// Routes pub/sub messages to other peers.
/// </summary>
public interface IMessageRouter : IService
{
/// <summary>
/// Sends the message to other peers.
/// </summary>
/// <param name="message">
/// The message to send.
/// </param>
/// <param name="cancel">
/// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation.
/// </returns>
Task PublishAsync(PublishedMessage message, CancellationToken cancel);
/// <summary>
/// Raised when a new message is received.
/// </summary>
event EventHandler<PublishedMessage> MessageReceived;
/// <summary>
/// Gets the sequence of peers interested in the topic.
/// </summary>
/// <param name="topic">
/// The topic of interest or <b>null</b> for all topics.
/// </param>
/// <returns>
/// A sequence of <see cref="Peer"/> that are subsribed to the
/// <paramref name="topic"/>.
/// </returns>
IEnumerable<Peer> InterestedPeers(string topic);
/// <summary>
/// Indicates that the local peer is interested in the topic.
/// </summary>
/// <param name="topic">
/// The topic of interested.
/// </param>
/// <param name="cancel">
/// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation.
/// </returns>
Task JoinTopicAsync(string topic, CancellationToken cancel);
/// <summary>
/// Indicates that the local peer is no longer interested in the topic.
/// </summary>
/// <param name="topic">
/// The topic of interested.
/// </param>
/// <param name="cancel">
/// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation.
/// </returns>
Task LeaveTopicAsync(string topic, CancellationToken cancel);
}
}