-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathITextTransportLayer.cs
More file actions
59 lines (52 loc) · 1.63 KB
/
ITextTransportLayer.cs
File metadata and controls
59 lines (52 loc) · 1.63 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
using System;
using System.Threading.Tasks;
using Waher.Events;
namespace Waher.Networking
{
/// <summary>
/// Event handler for text packet events.
/// </summary>
/// <param name="Sender">Sender of event.</param>
/// <param name="Text">Text packet.</param>
/// <returns>If the process should be continued.</returns>
public delegate Task<bool> TextEventHandler(object Sender, string Text);
/// <summary>
/// Interface for text transport layers.
/// </summary>
public interface ITextTransportLayer : IDisposableAsync
{
/// <summary>
/// Sends a text packet.
/// </summary>
/// <param name="Text">Text packet.</param>
/// <returns>If data was sent.</returns>
Task<bool> SendAsync(string Text);
/// <summary>
/// Sends a text packet.
/// </summary>
/// <param name="Text">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>
Task<bool> SendAsync(string Text, EventHandlerAsync<DeliveryEventArgs> DeliveryCallback, object State);
/// <summary>
/// Event raised when a packet has been sent.
/// </summary>
event TextEventHandler OnSent;
/// <summary>
/// Event received when text data has been received.
/// </summary>
event TextEventHandler OnReceived;
/// <summary>
/// If the reading is paused.
/// </summary>
bool Paused
{
get;
}
/// <summary>
/// Call this method to continue operation. Operation can be paused, by returning false from <see cref="OnReceived"/>.
/// </summary>
void Continue();
}
}