-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathAlternativeTransport.cs
More file actions
103 lines (89 loc) · 2.96 KB
/
AlternativeTransport.cs
File metadata and controls
103 lines (89 loc) · 2.96 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using System;
using System.Threading.Tasks;
using Waher.Events;
using Waher.Runtime.Inventory;
namespace Waher.Networking.XMPP
{
/// <summary>
/// Base class for alternative transports.
/// </summary>
public abstract class AlternativeTransport : IAlternativeTransport
{
/// <summary>
/// Event raised when a packet has been sent.
/// </summary>
public abstract event TextEventHandler OnSent;
/// <summary>
/// Event received when text data has been received.
/// </summary>
public abstract event TextEventHandler OnReceived;
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting
/// unmanaged resources.
/// </summary>
[Obsolete("Use DisposeAsync() instead")]
public void Dispose()
{
this.DisposeAsync().Wait();
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting
/// unmanaged resources.
/// </summary>
public abstract Task DisposeAsync();
/// <summary>
/// Sends a text packet.
/// </summary>
/// <param name="Packet">Text packet.</param>
/// <returns>If data was sent.</returns>
public abstract Task<bool> SendAsync(string Packet);
/// <summary>
/// Sends a text packet.
/// </summary>
/// <param name="Packet">Text packet.</param>
/// <param name="DeliveryCallback">Optional method to call when packet has been delivered.</param>
/// <param name="State">State object to pass on to callback method.</param>
/// <returns>If data was sent.</returns>
public abstract Task<bool> SendAsync(string Packet, EventHandlerAsync<DeliveryEventArgs> DeliveryCallback, object State);
/// <summary>
/// If the reading is paused.
/// </summary>
public abstract bool Paused
{
get;
}
/// <summary>
/// Call this method to continue operation. Operation can be paused, by returning false from <see cref="OnReceived"/>.
/// </summary>
public abstract void Continue();
/// <summary>
/// How well the alternative transport handles the XMPP credentials provided.
/// </summary>
/// <param name="URI">URI defining endpoint.</param>
/// <returns>Support grade.</returns>
public abstract Grade Supports(Uri URI);
/// <summary>
/// If the alternative binding mechanism handles heartbeats.
/// </summary>
public abstract bool HandlesHeartbeats
{
get;
}
/// <summary>
/// Instantiates a new alternative connections.
/// </summary>
/// <param name="URI">URI defining endpoint.</param>
/// <param name="Client">XMPP Client</param>
/// <param name="BindingInterface">Inteface to internal properties of the <see cref="XmppClient"/>.</param>
/// <returns>Instantiated binding.</returns>
public abstract IAlternativeTransport Instantiate(Uri URI, XmppClient Client, XmppBindingInterface BindingInterface);
/// <summary>
/// Creates a session.
/// </summary>
public abstract void CreateSession();
/// <summary>
/// Closes a session.
/// </summary>
public abstract void CloseSession();
}
}