-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathIBinaryTransportLayer.cs
More file actions
57 lines (51 loc) · 2.02 KB
/
IBinaryTransportLayer.cs
File metadata and controls
57 lines (51 loc) · 2.02 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
using System.Threading.Tasks;
namespace Waher.Networking
{
/// <summary>
/// Event handler for binary packet events.
/// </summary>
/// <param name="Sender">Sender of event.</param>
/// <param name="ConstantBuffer">If the contents of the buffer remains constant (true),
/// or if the contents in the buffer may change after the call (false).</param>
/// <param name="Buffer">Binary Data Buffer</param>
/// <param name="Offset">Start index of first byte written.</param>
/// <param name="Count">Number of bytes written.</param>
/// <returns>If the process should be continued.</returns>
public delegate Task BinaryDataWrittenEventHandler(object Sender, bool ConstantBuffer, byte[] Buffer, int Offset, int Count);
/// <summary>
/// Event handler for binary packet events.
/// </summary>
/// <param name="Sender">Sender of event.</param>
/// <param name="ConstantBuffer">If the contents of the buffer remains constant (true),
/// or if the contents in the buffer may change after the call (false).</param>
/// <param name="Buffer">Binary Data Buffer</param>
/// <param name="Offset">Start index of first byte read.</param>
/// <param name="Count">Number of bytes read.</param>
/// <returns>If the process should be continued.</returns>
public delegate Task<bool> BinaryDataReadEventHandler(object Sender, bool ConstantBuffer, byte[] Buffer, int Offset, int Count);
/// <summary>
/// Interface for binary transport layers.
/// </summary>
public interface IBinaryTransportLayer : IBinaryTransmission
{
/// <summary>
/// Event raised when a packet has been sent.
/// </summary>
event BinaryDataWrittenEventHandler OnSent;
/// <summary>
/// Event received when binary data has been received.
/// </summary>
event BinaryDataReadEventHandler 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();
}
}