| @@ -199,8 +199,8 @@ | |||||
| <Compile Include="..\Discord.Net\API\Client\GatewaySocket\Events\Ready.cs"> | <Compile Include="..\Discord.Net\API\Client\GatewaySocket\Events\Ready.cs"> | ||||
| <Link>API\Client\GatewaySocket\Events\Ready.cs</Link> | <Link>API\Client\GatewaySocket\Events\Ready.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\API\Client\GatewaySocket\Events\Redirect.cs"> | |||||
| <Link>API\Client\GatewaySocket\Events\Redirect.cs</Link> | |||||
| <Compile Include="..\Discord.Net\API\Client\GatewaySocket\Events\Reconnect.cs"> | |||||
| <Link>API\Client\GatewaySocket\Events\Reconnect.cs</Link> | |||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\API\Client\GatewaySocket\Events\Resumed.cs"> | <Compile Include="..\Discord.Net\API\Client\GatewaySocket\Events\Resumed.cs"> | ||||
| <Link>API\Client\GatewaySocket\Events\Resumed.cs</Link> | <Link>API\Client\GatewaySocket\Events\Resumed.cs</Link> | ||||
| @@ -10,8 +10,6 @@ namespace Discord.API.Client.GatewaySocket | |||||
| object IWebSocketMessage.Payload => this; | object IWebSocketMessage.Payload => this; | ||||
| bool IWebSocketMessage.IsPrivate => false; | bool IWebSocketMessage.IsPrivate => false; | ||||
| [JsonProperty("v")] | |||||
| public int Version { get; set; } | |||||
| [JsonProperty("token")] | [JsonProperty("token")] | ||||
| public string Token { get; set; } | public string Token { get; set; } | ||||
| [JsonProperty("properties")] | [JsonProperty("properties")] | ||||
| @@ -0,0 +1,6 @@ | |||||
| using Newtonsoft.Json; | |||||
| namespace Discord.API.Client.GatewaySocket | |||||
| { | |||||
| public class ReconnectEvent { } | |||||
| } | |||||
| @@ -1,10 +0,0 @@ | |||||
| using Newtonsoft.Json; | |||||
| namespace Discord.API.Client.GatewaySocket | |||||
| { | |||||
| public class RedirectEvent | |||||
| { | |||||
| [JsonProperty("url")] | |||||
| public string Url { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -17,7 +17,7 @@ | |||||
| /// <summary> C→S - Used to resume a connection after a redirect occurs. </summary> | /// <summary> C→S - Used to resume a connection after a redirect occurs. </summary> | ||||
| Resume = 6, | Resume = 6, | ||||
| /// <summary> C←S - Used to notify a client that they must reconnect to another gateway. </summary> | /// <summary> C←S - Used to notify a client that they must reconnect to another gateway. </summary> | ||||
| Redirect = 7, | |||||
| Reconnect = 7, | |||||
| /// <summary> C→S - Used to request all members that were withheld by large_threshold </summary> | /// <summary> C→S - Used to request all members that were withheld by large_threshold </summary> | ||||
| RequestGuildMembers = 8 | RequestGuildMembers = 8 | ||||
| } | } | ||||
| @@ -6,13 +6,13 @@ namespace Discord.API.Client.Rest | |||||
| public class GatewayRequest : IRestRequest<GatewayResponse> | public class GatewayRequest : IRestRequest<GatewayResponse> | ||||
| { | { | ||||
| string IRestRequest.Method => "GET"; | string IRestRequest.Method => "GET"; | ||||
| string IRestRequest.Endpoint => $"gateway"; | |||||
| string IRestRequest.Endpoint => $"gateway?encoding=json&v=4"; | |||||
| object IRestRequest.Payload => null; | object IRestRequest.Payload => null; | ||||
| } | } | ||||
| public class GatewayResponse | public class GatewayResponse | ||||
| { | |||||
| [JsonProperty("url")] | |||||
| public string Url { get; set; } | |||||
| { | |||||
| [JsonProperty("url")] | |||||
| public string Url { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -131,15 +131,10 @@ namespace Discord.Net.WebSockets | |||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| case OpCodes.Redirect: | |||||
| case OpCodes.Reconnect: | |||||
| { | { | ||||
| var payload = (msg.Payload as JToken).ToObject<RedirectEvent>(_serializer); | |||||
| if (payload.Url != null) | |||||
| { | |||||
| Host = payload.Url; | |||||
| Logger.Info("Redirected to " + payload.Url); | |||||
| await Reconnect().ConfigureAwait(false); | |||||
| } | |||||
| var payload = (msg.Payload as JToken).ToObject<ReconnectEvent>(_serializer); | |||||
| await Reconnect().ConfigureAwait(false); | |||||
| } | } | ||||
| break; | break; | ||||
| default: | default: | ||||
| @@ -159,7 +154,6 @@ namespace Discord.Net.WebSockets | |||||
| }; | }; | ||||
| var msg = new IdentifyCommand() | var msg = new IdentifyCommand() | ||||
| { | { | ||||
| Version = 3, | |||||
| Token = token, | Token = token, | ||||
| Properties = props, | Properties = props, | ||||
| LargeThreshold = _config.LargeThreshold, | LargeThreshold = _config.LargeThreshold, | ||||