2using System.Threading.Tasks;
13 private readonly Guid
id = Guid.NewGuid();
29 this.incoming = Incoming;
30 this.outgoing = Outgoing;
32 this.incoming.OnDisconnected += this.Incoming_OnDisconnected;
33 this.incoming.OnError += this.Incoming_OnError;
34 this.incoming.OnReceived += this.Incoming_OnReceived;
36 this.outgoing.OnDisconnected += this.Outgoing_OnDisconnected;
37 this.outgoing.OnError += this.Outgoing_OnError;
38 this.outgoing.OnReceived += this.Outgoing_OnReceived;
44 public Guid
Id => this.id;
53 this.incoming.DisposeWhenDone();
62 this.outgoing.DisposeWhenDone();
71 private async Task<bool> Outgoing_OnReceived(
object Sender,
byte[] Buffer,
int Offset,
int Count)
73 if (await this.incoming.SendAsync(Buffer, Offset, Count))
75 this.port.IncUplink(Count);
82 private Task Outgoing_OnError(
object Sender, Exception Exception)
84 this.port.Remove(
this);
85 return Task.CompletedTask;
88 private Task Outgoing_OnDisconnected(
object Sender, EventArgs e)
90 this.port.Remove(
this);
91 return Task.CompletedTask;
94 private async Task<bool> Incoming_OnReceived(
object Sender,
byte[] Buffer,
int Offset,
int Count)
96 if (await this.outgoing.SendAsync(Buffer, Offset, Count))
98 this.port.IncDownlink(Count);
105 private Task Incoming_OnError(
object Sender, Exception Exception)
107 this.port.Remove(
this);
108 return Task.CompletedTask;
111 private Task Incoming_OnDisconnected(
object Sender, EventArgs e)
113 this.port.Remove(
this);
114 return Task.CompletedTask;
Implements a binary TCP Client, by encapsulating a TcpClient. It also makes the use of TcpClient safe...
Simple base class for classes implementing communication protocols.
Task Exception(Exception Exception)
Called to inform the viewer of an exception state.
ISniffer[] Sniffers
Registered sniffers.
Maintains one proxy connection
ProxyClientConncetion(ProxyPort Port, BinaryTcpClient Incoming, BinaryTcpClient Outgoing, ISniffer[] Sniffers)
Maintains one proxy connection
void Dispose()
IDisposable.Dispose
Node acting as a TCP/IP proxy opening a port for incoming communication and proxying it to another po...
Interface for sniffers. Sniffers can be added to ICommunicationLayer classes to eavesdrop on communic...