From 95d9b745c64c5c751d0c6fd19ba8f4def656c1f8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Aug 2016 17:01:46 +0900 Subject: [PATCH] [Modify] Add it --- websocket-sharp/WebSocket.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4f4036b5..914561dc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1982,6 +1982,35 @@ namespace WebSocketSharp return true; } + internal static bool CheckParametersForClose ( + CloseStatusCode code, string reason, bool client, out string message + ) + { + message = null; + + if (code == CloseStatusCode.NoStatus && !reason.IsNullOrEmpty ()) { + message = "'code' cannot have a reason."; + return false; + } + + if (code == CloseStatusCode.MandatoryExtension && !client) { + message = "'code' cannot be used by a server."; + return false; + } + + if (code == CloseStatusCode.ServerError && client) { + message = "'code' cannot be used by a client."; + return false; + } + + if (!reason.IsNullOrEmpty () && reason.UTF8Encode ().Length > 123) { + message = "The size of 'reason' is greater than the allowable max size."; + return false; + } + + return true; + } + internal static string CheckPingParameter (string message, out byte[] bytes) { bytes = message.UTF8Encode ();