| @@ -1,7 +1,7 @@ | |||||
| <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
| <PropertyGroup> | <PropertyGroup> | ||||
| <VersionPrefix>2.4.0</VersionPrefix> | |||||
| <VersionSuffix></VersionSuffix> | |||||
| <VersionPrefix>2.4.1</VersionPrefix> | |||||
| <VersionSuffix>dev</VersionSuffix> | |||||
| <LangVersion>latest</LangVersion> | <LangVersion>latest</LangVersion> | ||||
| <Authors>Discord.Net Contributors</Authors> | <Authors>Discord.Net Contributors</Authors> | ||||
| <PackageTags>discord;discordapp</PackageTags> | <PackageTags>discord;discordapp</PackageTags> | ||||
| @@ -75,11 +75,6 @@ namespace Discord | |||||
| nextReconnectDelay = 1000; //Reset delay | nextReconnectDelay = 1000; //Reset delay | ||||
| await _connectionPromise.Task.ConfigureAwait(false); | await _connectionPromise.Task.ConfigureAwait(false); | ||||
| } | } | ||||
| catch (OperationCanceledException ex) | |||||
| { | |||||
| Cancel(); //In case this exception didn't come from another Error call | |||||
| await DisconnectAsync(ex, !reconnectCancelToken.IsCancellationRequested).ConfigureAwait(false); | |||||
| } | |||||
| catch (Exception ex) | catch (Exception ex) | ||||
| { | { | ||||
| Error(ex); //In case this exception didn't come from another Error call | Error(ex); //In case this exception didn't come from another Error call | ||||
| @@ -143,16 +138,7 @@ namespace Discord | |||||
| catch (OperationCanceledException) { } | catch (OperationCanceledException) { } | ||||
| }); | }); | ||||
| try | |||||
| { | |||||
| await _onConnecting().ConfigureAwait(false); | |||||
| } | |||||
| catch (TaskCanceledException ex) | |||||
| { | |||||
| Exception innerEx = ex.InnerException ?? new OperationCanceledException("Failed to connect."); | |||||
| Error(innerEx); | |||||
| throw innerEx; | |||||
| } | |||||
| await _onConnecting().ConfigureAwait(false); | |||||
| await _logger.InfoAsync("Connected").ConfigureAwait(false); | await _logger.InfoAsync("Connected").ConfigureAwait(false); | ||||
| State = ConnectionState.Connected; | State = ConnectionState.Connected; | ||||
| @@ -189,9 +189,9 @@ namespace Discord.API | |||||
| catch { } | catch { } | ||||
| if (ex is GatewayReconnectException) | if (ex is GatewayReconnectException) | ||||
| await WebSocketClient.DisconnectAsync(4000); | |||||
| await WebSocketClient.DisconnectAsync(4000).ConfigureAwait(false); | |||||
| else | else | ||||
| await WebSocketClient.DisconnectAsync().ConfigureAwait(false); | |||||
| await WebSocketClient.DisconnectAsync().ConfigureAwait(false); | |||||
| ConnectionState = ConnectionState.Disconnected; | ConnectionState = ConnectionState.Disconnected; | ||||
| } | } | ||||
| @@ -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; | ||||
| @@ -2,7 +2,7 @@ | |||||
| <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||||
| <metadata> | <metadata> | ||||
| <id>Discord.Net</id> | <id>Discord.Net</id> | ||||
| <version>2.4.0$suffix$</version> | |||||
| <version>2.4.1-dev$suffix$</version> | |||||
| <title>Discord.Net</title> | <title>Discord.Net</title> | ||||
| <authors>Discord.Net Contributors</authors> | <authors>Discord.Net Contributors</authors> | ||||
| <owners>foxbot</owners> | <owners>foxbot</owners> | ||||
| @@ -14,25 +14,25 @@ | |||||
| <iconUrl>https://github.com/RogueException/Discord.Net/raw/dev/docs/marketing/logo/PackageLogo.png</iconUrl> | <iconUrl>https://github.com/RogueException/Discord.Net/raw/dev/docs/marketing/logo/PackageLogo.png</iconUrl> | ||||
| <dependencies> | <dependencies> | ||||
| <group targetFramework="net461"> | <group targetFramework="net461"> | ||||
| <dependency id="Discord.Net.Core" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.Rest" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.WebSocket" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.Commands" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.Webhook" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.Core" version="2.4.1-dev$suffix$" /> | |||||
| <dependency id="Discord.Net.Rest" version="2.4.1-dev$suffix$" /> | |||||
| <dependency id="Discord.Net.WebSocket" version="2.4.1-dev$suffix$" /> | |||||
| <dependency id="Discord.Net.Commands" version="2.4.1-dev$suffix$" /> | |||||
| <dependency id="Discord.Net.Webhook" version="2.4.1-dev$suffix$" /> | |||||
| </group> | </group> | ||||
| <group targetFramework="netstandard2.0"> | <group targetFramework="netstandard2.0"> | ||||
| <dependency id="Discord.Net.Core" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.Rest" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.WebSocket" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.Commands" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.Webhook" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.Core" version="2.4.1-dev$suffix$" /> | |||||
| <dependency id="Discord.Net.Rest" version="2.4.1-dev$suffix$" /> | |||||
| <dependency id="Discord.Net.WebSocket" version="2.4.1-dev$suffix$" /> | |||||
| <dependency id="Discord.Net.Commands" version="2.4.1-dev$suffix$" /> | |||||
| <dependency id="Discord.Net.Webhook" version="2.4.1-dev$suffix$" /> | |||||
| </group> | </group> | ||||
| <group targetFramework="netstandard2.1"> | <group targetFramework="netstandard2.1"> | ||||
| <dependency id="Discord.Net.Core" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.Rest" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.WebSocket" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.Commands" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.Webhook" version="2.4.0$suffix$" /> | |||||
| <dependency id="Discord.Net.Core" version="2.4.1-dev$suffix$" /> | |||||
| <dependency id="Discord.Net.Rest" version="2.4.1-dev$suffix$" /> | |||||
| <dependency id="Discord.Net.WebSocket" version="2.4.1-dev$suffix$" /> | |||||
| <dependency id="Discord.Net.Commands" version="2.4.1-dev$suffix$" /> | |||||
| <dependency id="Discord.Net.Webhook" version="2.4.1-dev$suffix$" /> | |||||
| </group> | </group> | ||||
| </dependencies> | </dependencies> | ||||
| </metadata> | </metadata> | ||||