mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
Makes CancellationToken optional in TcpTransport
This commit is contained in:
parent
2a2937aedf
commit
de79619b05
|
|
@ -33,7 +33,7 @@ namespace TLSharp.Core.Network
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Send(byte[] packet, CancellationToken token)
|
public async Task Send(byte[] packet, CancellationToken token = default(CancellationToken))
|
||||||
{
|
{
|
||||||
if (!_tcpClient.Connected)
|
if (!_tcpClient.Connected)
|
||||||
throw new InvalidOperationException("Client not connected to server.");
|
throw new InvalidOperationException("Client not connected to server.");
|
||||||
|
|
@ -44,7 +44,7 @@ namespace TLSharp.Core.Network
|
||||||
sendCounter++;
|
sendCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TcpMessage> Receive(CancellationToken token)
|
public async Task<TcpMessage> Receive(CancellationToken token = default(CancellationToken))
|
||||||
{
|
{
|
||||||
var packetLengthBytes = new byte[4];
|
var packetLengthBytes = new byte[4];
|
||||||
if (await _stream.ReadAsync(packetLengthBytes, 0, 4, token).ConfigureAwait(false) != 4)
|
if (await _stream.ReadAsync(packetLengthBytes, 0, 4, token).ConfigureAwait(false) != 4)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue