From f6dacb7a846b575785258d8ce797e604e0498307 Mon Sep 17 00:00:00 2001 From: Brandon Smith Date: Fri, 4 Sep 2015 19:32:26 -0300 Subject: [PATCH] Do not allow ObjectDisposed exceptions to trigger disconnectreason --- src/Discord.Net/DiscordWebSocket.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net/DiscordWebSocket.cs b/src/Discord.Net/DiscordWebSocket.cs index 3a8f28a29..3ef623d15 100644 --- a/src/Discord.Net/DiscordWebSocket.cs +++ b/src/Discord.Net/DiscordWebSocket.cs @@ -146,11 +146,11 @@ namespace Discord if (_webSocket.State != WebSocketState.Open || cancelToken.IsCancellationRequested) return; - try + try { result = await _webSocket.ReceiveAsync(new ArraySegment(buffer), cancelToken); } - catch (Win32Exception ex) + catch (Win32Exception ex) when (ex.HResult == HR_TIMEOUT) { string msg = $"Connection timed out."; @@ -182,6 +182,7 @@ namespace Discord } } catch (OperationCanceledException) { } + catch (ObjectDisposedException) { } catch (Exception ex) { DisconnectInternal(ex); } } private async Task SendAsync() @@ -210,6 +211,7 @@ namespace Discord } } catch (OperationCanceledException) { } + catch (ObjectDisposedException) { } catch (Exception ex) { DisconnectInternal(ex); } }