From 09fd6ca410e04da10fb512031693ee5e00d728b1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Jun 2018 20:16:21 +0900 Subject: [PATCH] [Modify] Throw exceptions --- websocket-sharp/Server/WebSocketBehavior.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1a2169aa..39f82d82 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -264,11 +264,18 @@ namespace WebSocketSharp.Server } set { - if (State != WebSocketState.Connecting) - return; + if (State != WebSocketState.Connecting) { + var msg = "The session has already started."; + throw new InvalidOperationException (msg); + } - if (value != null && (value.Length == 0 || !value.IsToken ())) + if (value == null || value.Length == 0) { + _protocol = null; return; + } + + if (!value.IsToken ()) + throw new ArgumentException ("Not a token.", "value"); _protocol = value; }