Added handling of opcode-less messages

This commit is contained in:
RogueException
2015-12-25 23:11:55 -04:00
parent 2e34b67250
commit 3d9dadaaae
2 changed files with 7 additions and 4 deletions

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)]

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;
}
}