2using System.Threading.Tasks;
4using Windows.Networking.Sockets;
6using System.Net.Sockets;
19 private readonly StringBuilder buffer =
new StringBuilder();
20 private readonly
int maxLen = 0;
21 private char prev = (char)0;
22 private bool error =
false;
38 this.maxLen = MaxLength;
55 this.maxLen = MaxLength;
73 this.maxLen = MaxLength;
91 this.maxLen = MaxLength;
108 this.maxLen = MaxLength;
126 this.maxLen = MaxLength;
136 foreach (
char ch
in Data)
138 if (ch ==
'\r' || ch ==
'\n')
142 if (this.prev == ch && !await base.TextDataReceived(
string.Empty))
149 await this.
Error(
"Row too long: " + this.len.ToString() +
" characters");
152 else if (!await base.TextDataReceived(
this.buffer.ToString()))
162 if (this.len++ > this.maxLen)
165 this.buffer.Append(ch);
181 return this.
SendAsync(Packet,
null,
null);
191 public override Task<bool>
SendAsync(
string Text, EventHandlerAsync<DeliveryEventArgs> Callback,
object State)
193 return base.SendAsync(Text +
"\r\n", Callback, State);
202 return base.TextDataSent(Data.Substring(0, Data.Length - 2));
TcpClient Client
Underlying TcpClient object.
Task Error(string Error)
Called to inform the viewer of an error state.
bool DecoupledEvents
If events raised from the communication layer are decoupled, i.e. executed in parallel with the sourc...
Implements a text-based TCP Client, by using the thread-safe full-duplex BinaryTcpClient....
RowTcpClient(Encoding Encoding, int MaxLength, bool SniffText, bool DecoupledEvents, params ISniffer[] Sniffers)
Implements a text-based TCP Client, by using the thread-safe full-duplex BinaryTcpClient....
RowTcpClient(Encoding Encoding, int MaxLength, bool DecoupledEvents, params ISniffer[] Sniffers)
Implements a text-based TCP Client, by using the thread-safe full-duplex BinaryTcpClient....
RowTcpClient(TcpClient Client, Encoding Encoding, int MaxLength, bool SniffText, bool DecoupledEvents, params ISniffer[] Sniffers)
Implements a text-based TCP Client, by using the thread-safe full-duplex BinaryTcpClient....
async override Task< bool > TextDataReceived(string Data)
Method called when text data has been received.
RowTcpClient(TcpClient Client, Encoding Encoding, int MaxLength, bool DecoupledEvents, params ISniffer[] Sniffers)
Implements a text-based TCP Client, by using the thread-safe full-duplex BinaryTcpClient....
override Task< bool > SendAsync(string Packet)
Sends a text packet.
override Task< bool > SendAsync(string Text, EventHandlerAsync< DeliveryEventArgs > Callback, object State)
Sends a binary packet.
override Task TextDataSent(string Data)
Method called when binary data has been sent.
Implements a text-based TCP Client, by using the thread-safe full-duplex BinaryTcpClient.
Encoding Encoding
Text encoding to use.
Interface for sniffers. Sniffers can be added to ICommunicationLayer classes to eavesdrop on communic...