-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathISubscriber.cs
78 lines (67 loc) · 3.07 KB
/
ISubscriber.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
77
78
using WalletConnectSharp.Common;
using WalletConnectSharp.Core.Models.Relay;
using WalletConnectSharp.Core.Models.Subscriber;
namespace WalletConnectSharp.Core.Interfaces
{
/// <summary>
/// An interface representing the Subscriber module. This module handles both subscribing to events as well as keeping track
/// of active and pending subscriptions. It will also resubscribe to topics if
/// the backing Relayer connection disconnects
/// </summary>
public interface ISubscriber : IModule
{
event EventHandler Sync;
event EventHandler Resubscribed;
event EventHandler<ActiveSubscription> Created;
event EventHandler<DeletedSubscription> Deleted;
/// <summary>
/// A dictionary of active subscriptions where the key is the id of the Subscription
/// </summary>
public IReadOnlyDictionary<string, ActiveSubscription> Subscriptions { get; }
/// <summary>
/// A subscription mapping of Topics => Subscription ids
/// </summary>
public ISubscriberMap TopicMap { get; }
/// <summary>
/// The number of active subscriptions
/// </summary>
public int Length { get; }
/// <summary>
/// An array of active subscription Ids
/// </summary>
public string[] Ids { get; }
/// <summary>
/// An array of active Subscriptions
/// </summary>
public ActiveSubscription[] Values { get; }
/// <summary>
/// An array of topics that are currently subscribed
/// </summary>
public string[] Topics { get; }
/// <summary>
/// Initialize this Subscriber, which will restore + resubscribe to all active subscriptions found
/// in storage
/// </summary>
public Task Init();
/// <summary>
/// Subscribe to a new topic with (optional) SubscribeOptions
/// </summary>
/// <param name="topic">The topic to subscribe to</param>
/// <param name="opts">Options to determine the protocol to use for subscribing</param>
/// <returns>The subscription id</returns>
public Task<string> Subscribe(string topic, SubscribeOptions opts = null);
/// <summary>
/// Unsubscribe to a given topic with optional UnsubscribeOptions
/// </summary>
/// <param name="topic">The topic to unsubscribe from</param>
/// <param name="opts">The options to specify the subscription id as well as protocol options</param>
public Task Unsubscribe(string topic, UnsubscribeOptions opts = null);
/// <summary>
/// Determines whether the given topic is subscribed or not
/// </summary>
/// <param name="topic">The topic to check</param>
/// /// <param name="cancellationToken">A token to cancel the operation.</param>
/// <returns>Return true if the topic is subscribed, false otherwise</returns>
public Task<bool> IsSubscribed(string topic, CancellationToken cancellationToken = default);
}
}