Browse Source

Added handling of opcode-less messages

tags/docs-0.9
RogueException 9 years ago
parent
commit
3d9dadaaae
2 changed files with 7 additions and 4 deletions
  1. +1
    -1
      src/Discord.Net/API/Client/IWebSocketMessage.cs
  2. +6
    -3
      src/Discord.Net/Net/WebSockets/GatewaySocket.cs

+ 1
- 1
src/Discord.Net/API/Client/IWebSocketMessage.cs View File

@@ -11,7 +11,7 @@ namespace Discord.API.Client
public class WebSocketMessage
{
[JsonProperty("op")]
public int Operation { get; set; }
public int? Operation { get; set; }
[JsonProperty("t", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("s", NullValueHandling = NullValueHandling.Ignore)]


+ 6
- 3
src/Discord.Net/Net/WebSockets/GatewaySocket.cs View File

@@ -77,7 +77,7 @@ namespace Discord.Net.WebSockets
if (msg.Sequence.HasValue)
_lastSequence = msg.Sequence.Value;

var opCode = (OpCodes)msg.Operation;
var opCode = (OpCodes?)msg.Operation;
switch (opCode)
{
case OpCodes.Dispatch:
@@ -111,8 +111,11 @@ namespace Discord.Net.WebSockets
}
break;
default:
Logger.Warning($"Unknown Opcode: {opCode}");
break;
if (opCode != null)
Logger.Warning($"Unknown Opcode: {opCode}");
else
Logger.Warning($"Received message with no opcode");
break;
}
}



Loading…
Cancel
Save