Cancel session if a bad message is received

This commit is contained in:
Frank A. Krueger 2017-06-15 21:29:57 -07:00
parent 8e1da8c190
commit 10b2a55df1
1 changed files with 2 additions and 0 deletions

View File

@ -366,9 +366,11 @@ namespace Ooui
if (receiveResult.MessageType == WebSocketMessageType.Close) { if (receiveResult.MessageType == WebSocketMessageType.Close) {
await webSocket.CloseAsync (WebSocketCloseStatus.NormalClosure, "", token).ConfigureAwait (false); await webSocket.CloseAsync (WebSocketCloseStatus.NormalClosure, "", token).ConfigureAwait (false);
sessionCts.Cancel ();
} }
else if (receiveResult.MessageType == WebSocketMessageType.Binary) { else if (receiveResult.MessageType == WebSocketMessageType.Binary) {
await webSocket.CloseAsync (WebSocketCloseStatus.InvalidMessageType, "Cannot accept binary frame", token).ConfigureAwait (false); await webSocket.CloseAsync (WebSocketCloseStatus.InvalidMessageType, "Cannot accept binary frame", token).ConfigureAwait (false);
sessionCts.Cancel ();
} }
else { else {
var size = receiveResult.Count; var size = receiveResult.Count;