@@ -193,6 +193,12 @@ namespace Discord | |||||
_reconnectCancelToken?.Cancel(); | _reconnectCancelToken?.Cancel(); | ||||
Error(ex); | Error(ex); | ||||
} | } | ||||
public void Reconnect() | |||||
{ | |||||
_readyPromise.TrySetCanceled(); | |||||
_connectionPromise.TrySetCanceled(); | |||||
_connectionCancelToken?.Cancel(); | |||||
} | |||||
private async Task AcquireConnectionLock() | private async Task AcquireConnectionLock() | ||||
{ | { | ||||
while (true) | while (true) | ||||
@@ -433,7 +433,11 @@ namespace Discord.WebSocket | |||||
_sessionId = null; | _sessionId = null; | ||||
_lastSeq = 0; | _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; | break; | ||||
case GatewayOpCode.Reconnect: | case GatewayOpCode.Reconnect: | ||||
@@ -5,11 +5,11 @@ using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.IO; | using System.IO; | ||||
using System.Net; | using System.Net; | ||||
using System.Reactive.Concurrency; | |||||
using System.Reactive.Linq; | using System.Reactive.Linq; | ||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using Splat; | using Splat; | ||||
using System.Reactive.Concurrency; | |||||
namespace Discord.Net | namespace Discord.Net | ||||
{ | { | ||||