Browse Source

Fix serialization error

pull/1923/head
quin lynch 3 years ago
parent
commit
cc5fc8d288
3 changed files with 26 additions and 5 deletions
  1. +2
    -2
      src/Discord.Net.Rest/API/Common/Game.cs
  2. +10
    -0
      src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml
  3. +14
    -3
      src/Discord.Net.WebSocket/DiscordSocketApiClient.cs

+ 2
- 2
src/Discord.Net.Rest/API/Common/Game.cs View File

@@ -41,8 +41,8 @@ namespace Discord.API
public Optional<Emoji> Emoji { get; set; } public Optional<Emoji> Emoji { get; set; }
[JsonProperty("created_at")] [JsonProperty("created_at")]
public Optional<long> CreatedAt { get; set; } public Optional<long> CreatedAt { get; set; }
[JsonProperty("buttons")]
public Optional<RichPresenceButton[]> Buttons { get; set; }
//[JsonProperty("buttons")]
//public Optional<RichPresenceButton[]> Buttons { get; set; }


[OnError] [OnError]
internal void OnError(StreamingContext context, ErrorContext errorContext) internal void OnError(StreamingContext context, ErrorContext errorContext)


+ 10
- 0
src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml View File

@@ -3628,6 +3628,16 @@
<member name="M:Discord.WebSocket.SocketMessageComponent.FollowupAsync(System.String,Discord.Embed[],System.Boolean,System.Boolean,Discord.AllowedMentions,Discord.RequestOptions,Discord.MessageComponent,Discord.Embed)"> <member name="M:Discord.WebSocket.SocketMessageComponent.FollowupAsync(System.String,Discord.Embed[],System.Boolean,System.Boolean,Discord.AllowedMentions,Discord.RequestOptions,Discord.MessageComponent,Discord.Embed)">
<inheritdoc/> <inheritdoc/>
</member> </member>
<member name="M:Discord.WebSocket.SocketMessageComponent.DeferLoadingAsync(System.Boolean,Discord.RequestOptions)">
<summary>
Defers an interaction and responds with type 5 (<see cref="F:Discord.InteractionResponseType.DeferredChannelMessageWithSource"/>)
</summary>
<param name="ephemeral"><see langword="true"/> to send this message ephemerally, otherwise <see langword="false"/>.</param>
<param name="options">The request options for this async request.</param>
<returns>
A task that represents the asynchronous operation of acknowledging the interaction.
</returns>
</member>
<member name="M:Discord.WebSocket.SocketMessageComponent.DeferAsync(System.Boolean,Discord.RequestOptions)"> <member name="M:Discord.WebSocket.SocketMessageComponent.DeferAsync(System.Boolean,Discord.RequestOptions)">
<inheritdoc/> <inheritdoc/>
</member> </member>


+ 14
- 3
src/Discord.Net.WebSocket/DiscordSocketApiClient.cs View File

@@ -79,7 +79,7 @@ namespace Discord.API
if (msg != null) if (msg != null)
{ {
#if DEBUG_PACKETS #if DEBUG_PACKETS
Console.WriteLine($"<- {msg.Operation} [{msg.Type ?? "none"}] : {(msg.Payload as Newtonsoft.Json.Linq.JToken)?.ToString().Length}");
Console.WriteLine($"<- {(GatewayOpCode)msg.Operation} [{msg.Type ?? "none"}] : {(msg.Payload as Newtonsoft.Json.Linq.JToken)?.ToString().Length}");
#endif #endif


await _receivedGatewayEvent.InvokeAsync((GatewayOpCode)msg.Operation, msg.Sequence, msg.Type, msg.Payload).ConfigureAwait(false); await _receivedGatewayEvent.InvokeAsync((GatewayOpCode)msg.Operation, msg.Sequence, msg.Type, msg.Payload).ConfigureAwait(false);
@@ -96,7 +96,7 @@ namespace Discord.API
if (msg != null) if (msg != null)
{ {
#if DEBUG_PACKETS #if DEBUG_PACKETS
Console.WriteLine($"<- {msg.Operation} [{msg.Type ?? "none"}] : {(msg.Payload as Newtonsoft.Json.Linq.JToken)?.ToString().Length}");
Console.WriteLine($"<- {(GatewayOpCode)msg.Operation} [{msg.Type ?? "none"}] : {(msg.Payload as Newtonsoft.Json.Linq.JToken)?.ToString().Length}");
#endif #endif


await _receivedGatewayEvent.InvokeAsync((GatewayOpCode)msg.Operation, msg.Sequence, msg.Type, msg.Payload).ConfigureAwait(false); await _receivedGatewayEvent.InvokeAsync((GatewayOpCode)msg.Operation, msg.Sequence, msg.Type, msg.Payload).ConfigureAwait(false);
@@ -105,6 +105,10 @@ namespace Discord.API
}; };
WebSocketClient.Closed += async ex => WebSocketClient.Closed += async ex =>
{ {
#if DEBUG_PACKETS
Console.WriteLine(ex);
#endif

await DisconnectAsync().ConfigureAwait(false); await DisconnectAsync().ConfigureAwait(false);
await _disconnectedEvent.InvokeAsync(ex).ConfigureAwait(false); await _disconnectedEvent.InvokeAsync(ex).ConfigureAwait(false);
}; };
@@ -166,6 +170,11 @@ namespace Discord.API
var gatewayResponse = await GetGatewayAsync().ConfigureAwait(false); var gatewayResponse = await GetGatewayAsync().ConfigureAwait(false);
_gatewayUrl = $"{gatewayResponse.Url}?v={DiscordConfig.APIVersion}&encoding={DiscordSocketConfig.GatewayEncoding}&compress=zlib-stream"; _gatewayUrl = $"{gatewayResponse.Url}?v={DiscordConfig.APIVersion}&encoding={DiscordSocketConfig.GatewayEncoding}&compress=zlib-stream";
} }

#if DEBUG
Console.WriteLine("Connecting to gateway: " + _gatewayUrl);
#endif

await WebSocketClient.ConnectAsync(_gatewayUrl).ConfigureAwait(false); await WebSocketClient.ConnectAsync(_gatewayUrl).ConfigureAwait(false);


ConnectionState = ConnectionState.Connected; ConnectionState = ConnectionState.Connected;
@@ -237,7 +246,9 @@ namespace Discord.API
options = RequestOptions.CreateOrClone(options); options = RequestOptions.CreateOrClone(options);
var props = new Dictionary<string, string> var props = new Dictionary<string, string>
{ {
["$device"] = "Discord.Net Labs"
["$device"] = "Discord.Net Labs",
["$os"] = Environment.OSVersion.Platform.ToString(),
[$"browser"] = "Discord.Net Labs"
}; };
var msg = new IdentifyParams() var msg = new IdentifyParams()
{ {


Loading…
Cancel
Save