From af478f224f439980a87997b4afc4005630c332bd Mon Sep 17 00:00:00 2001 From: Sentinent Date: Thu, 17 Nov 2016 23:26:10 -0800 Subject: [PATCH] Fixed connecting with user tokens and updated gateway OP codes --- src/Discord.Net/API/Client/GatewaySocket/Commands/Identify.cs | 2 +- src/Discord.Net/API/Client/GatewaySocket/OpCodes.cs | 10 ++++++++-- src/Discord.Net/Net/WebSockets/GatewaySocket.cs | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Discord.Net/API/Client/GatewaySocket/Commands/Identify.cs b/src/Discord.Net/API/Client/GatewaySocket/Commands/Identify.cs index ffa5feb44..a88a2fad1 100644 --- a/src/Discord.Net/API/Client/GatewaySocket/Commands/Identify.cs +++ b/src/Discord.Net/API/Client/GatewaySocket/Commands/Identify.cs @@ -18,7 +18,7 @@ namespace Discord.API.Client.GatewaySocket public int LargeThreshold { get; set; } [JsonProperty("compress")] public bool UseCompression { get; set; } - [JsonProperty("shard")] + [JsonProperty("shard", NullValueHandling = NullValueHandling.Ignore)] public int[] ShardingParams { get; set; } } } diff --git a/src/Discord.Net/API/Client/GatewaySocket/OpCodes.cs b/src/Discord.Net/API/Client/GatewaySocket/OpCodes.cs index 497b4d3e2..249b7327d 100644 --- a/src/Discord.Net/API/Client/GatewaySocket/OpCodes.cs +++ b/src/Discord.Net/API/Client/GatewaySocket/OpCodes.cs @@ -18,7 +18,13 @@ Resume = 6, /// C←S - Used to notify a client that they must reconnect to another gateway. Reconnect = 7, - /// C→S - Used to request all members that were withheld by large_threshold - RequestGuildMembers = 8 + /// C→S - Used to request all members that were withheld by large_threshold. + RequestGuildMembers = 8, + /// C←S - Used to notify the client of an invalid session id. + InvalidSession = 9, + /// C←S - Used to receive heartbeat_interval information and initiate the websocket connection. + Hello = 10, + /// C←S - Used to acknowledge a heartbeat by the client. + HeartbeatACK = 11 } } diff --git a/src/Discord.Net/Net/WebSockets/GatewaySocket.cs b/src/Discord.Net/Net/WebSockets/GatewaySocket.cs index 8f19983ee..bcb925e9d 100644 --- a/src/Discord.Net/Net/WebSockets/GatewaySocket.cs +++ b/src/Discord.Net/Net/WebSockets/GatewaySocket.cs @@ -157,10 +157,10 @@ namespace Discord.Net.WebSockets var msg = new IdentifyCommand() { Token = token, - Properties = props, + Properties = props, LargeThreshold = _config.LargeThreshold, UseCompression = true, - ShardingParams = new int[] { shardId, totalShards }, + ShardingParams = token.StartsWith("Bot ") ? new int[] { shardId, totalShards } : null }; QueueMessage(msg);