|
@@ -108,11 +108,11 @@ namespace Discord.Net.WebSockets |
|
|
} |
|
|
} |
|
|
private async Task DisconnectInternalAsync(int closeCode = 1000, bool isDisposing = false) |
|
|
private async Task DisconnectInternalAsync(int closeCode = 1000, bool isDisposing = false) |
|
|
{ |
|
|
{ |
|
|
|
|
|
_isDisconnecting = true; |
|
|
|
|
|
|
|
|
try { _disconnectTokenSource.Cancel(false); } |
|
|
try { _disconnectTokenSource.Cancel(false); } |
|
|
catch { } |
|
|
catch { } |
|
|
|
|
|
|
|
|
_isDisconnecting = true; |
|
|
|
|
|
|
|
|
|
|
|
if (_client != null) |
|
|
if (_client != null) |
|
|
{ |
|
|
{ |
|
|
if (!isDisposing) |
|
|
if (!isDisposing) |
|
@@ -166,7 +166,14 @@ namespace Discord.Net.WebSockets |
|
|
|
|
|
|
|
|
public async Task SendAsync(byte[] data, int index, int count, bool isText) |
|
|
public async Task SendAsync(byte[] data, int index, int count, bool isText) |
|
|
{ |
|
|
{ |
|
|
await _lock.WaitAsync().ConfigureAwait(false); |
|
|
|
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
await _lock.WaitAsync(_cancelToken).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
catch (TaskCanceledException) |
|
|
|
|
|
{ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
if (_client == null) return; |
|
|
if (_client == null) return; |
|
@@ -201,7 +208,7 @@ namespace Discord.Net.WebSockets |
|
|
{ |
|
|
{ |
|
|
while (!cancelToken.IsCancellationRequested) |
|
|
while (!cancelToken.IsCancellationRequested) |
|
|
{ |
|
|
{ |
|
|
WebSocketReceiveResult socketResult = await _client.ReceiveAsync(buffer, CancellationToken.None).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
WebSocketReceiveResult socketResult = await _client.ReceiveAsync(buffer, cancelToken).ConfigureAwait(false); |
|
|
byte[] result; |
|
|
byte[] result; |
|
|
int resultCount; |
|
|
int resultCount; |
|
|
|
|
|
|
|
|