From dc4f17ef00fca4acfe3752389a88663ad2464112 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Dec 2020 19:45:16 +0900 Subject: [PATCH] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 390ca563..ca4e0466 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -287,18 +287,28 @@ namespace WebSocketSharp.Net /// public HttpListenerWebSocketContext AcceptWebSocket (string protocol) { - if (_websocketContext != null) - throw new InvalidOperationException ("The accepting is already in progress."); + if (_websocketContext != null) { + var msg = "The accepting is already in progress."; + + throw new InvalidOperationException (msg); + } if (protocol != null) { - if (protocol.Length == 0) - throw new ArgumentException ("An empty string.", "protocol"); + if (protocol.Length == 0) { + var msg = "An empty string."; - if (!protocol.IsToken ()) - throw new ArgumentException ("Contains an invalid character.", "protocol"); + throw new ArgumentException (msg, "protocol"); + } + + if (!protocol.IsToken ()) { + var msg = "It contains an invalid character."; + + throw new ArgumentException (msg, "protocol"); + } } _websocketContext = new HttpListenerWebSocketContext (this, protocol); + return _websocketContext; }