Browse Source

Support InvalidSession(true)

tags/1.0-rc
RogueException 8 years ago
parent
commit
3a45e9ec87
3 changed files with 12 additions and 2 deletions
  1. +6
    -0
      src/Discord.Net.WebSocket/ConnectionManager.cs
  2. +5
    -1
      src/Discord.Net.WebSocket/DiscordSocketClient.cs
  3. +1
    -1
      test/Discord.Net.Tests/Net/CachedRestClient.cs

+ 6
- 0
src/Discord.Net.WebSocket/ConnectionManager.cs View File

@@ -193,6 +193,12 @@ namespace Discord
_reconnectCancelToken?.Cancel();
Error(ex);
}
public void Reconnect()
{
_readyPromise.TrySetCanceled();
_connectionPromise.TrySetCanceled();
_connectionCancelToken?.Cancel();
}
private async Task AcquireConnectionLock()
{
while (true)


+ 5
- 1
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -433,7 +433,11 @@ namespace Discord.WebSocket

_sessionId = null;
_lastSeq = 0;
await ApiClient.SendIdentifyAsync(shardID: ShardId, totalShards: TotalShards).ConfigureAwait(false);
bool retry = (bool)payload;
if (retry)
_connection.Reconnect(); //TODO: Untested
else
await ApiClient.SendIdentifyAsync(shardID: ShardId, totalShards: TotalShards).ConfigureAwait(false);
}
break;
case GatewayOpCode.Reconnect:


+ 1
- 1
test/Discord.Net.Tests/Net/CachedRestClient.cs View File

@@ -5,11 +5,11 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Threading;
using System.Threading.Tasks;
using Splat;
using System.Reactive.Concurrency;

namespace Discord.Net
{


Loading…
Cancel
Save