From 2c8ca0a49144fc9bcebad04a7ee3ed38241b3f68 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Jan 2015 15:45:04 +0900 Subject: [PATCH] Added the CheckIfValidCloseParameters (ushort, string) method --- websocket-sharp/Ext.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index dd3342fd..257cdba5 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -251,6 +251,17 @@ namespace WebSocketSharp : null; } + internal static string CheckIfValidCloseParameters (this ushort code, string reason) + { + return !code.IsCloseStatusCode () + ? "An invalid close status code." + : 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 ()