-
Notifications
You must be signed in to change notification settings - Fork 16
/
IPeerProtocol.cs
50 lines (46 loc) · 1.41 KB
/
IPeerProtocol.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
using Ipfs;
using Semver;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace PeerTalk.Protocols
{
/// <summary>
/// Defines the messages that can be exchanged between two peers.
/// </summary>
/// <remarks>
/// <see cref="Object.ToString"/> must return a string in the form
/// "/name/version".
/// </remarks>
public interface IPeerProtocol
{
/// <summary>
/// The name of the protocol.
/// </summary>
string Name { get; }
/// <summary>
/// The version of the protocol.
/// </summary>
SemVersion Version { get; }
/// <summary>
/// Process a message for the protocol.
/// </summary>
/// <param name="connection">
/// A connection between two peers.
/// </param>
/// <param name="stream">
/// The message source.
/// </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 ProcessMessageAsync(PeerConnection connection, Stream stream, CancellationToken cancel = default(CancellationToken));
}
}