From 1bb7775a7e8e0ac808cb34d2387196fa1246d9f1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Jan 2015 17:51:09 +0900 Subject: [PATCH] Added the CheckIfValidCloseParameters (CloseStatusCode, string) method --- websocket-sharp/Ext.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 257cdba5..79ab0b86 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -262,6 +262,15 @@ namespace WebSocketSharp : null; } + internal static string CheckIfValidCloseParameters (this CloseStatusCode code, string reason) + { + return code.IsNoStatusCode () && !reason.IsNullOrEmpty () + ? "NoStatusCode cannot have a reason." + : !reason.IsNullOrEmpty () && Encoding.UTF8.GetBytes (reason).Length > 123 + ? "A reason has greater than the allowable max size." + : null; + } + internal static string CheckIfValidCloseStatusCode (this ushort code) { return !code.IsCloseStatusCode ()