From efec2020b03021c7bc8946108dcbd3d65312c2db Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Sep 2017 19:26:04 +0900 Subject: [PATCH] [Modify] Throw exception --- websocket-sharp/WebSocket.cs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4167d44b..b44cea36 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -608,14 +608,27 @@ namespace WebSocketSharp } set { - lock (_forState) { - string msg; - if (!checkIfAvailable (true, true, true, false, false, true, out msg) - || !value.CheckWaitTime (out msg) - ) { - _logger.Error (msg); - error ("An error has occurred in setting the wait time.", null); + if (value <= TimeSpan.Zero) + throw new ArgumentOutOfRangeException ("value", "Zero or less."); + if (_readyState == WebSocketState.Open) { + _logger.Warn ("The connection has already been established."); + return; + } + + if (_readyState == WebSocketState.Closing) { + _logger.Warn ("The connection is closing."); + return; + } + + lock (_forState) { + if (_readyState == WebSocketState.Open) { + _logger.Warn ("The connection has already been established."); + return; + } + + if (_readyState == WebSocketState.Closing) { + _logger.Warn ("The connection is closing."); return; }