diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 179fcc20..0e0f6ded 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2255,10 +2255,15 @@ namespace WebSocketSharp /// public void Close (ushort code) { - var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? - CheckCloseParameters (code, null, _client); + string msg; + if (!checkIfAvailable (true, true, false, false, out msg)) { + _logger.Error (msg); + error ("An error has occurred in closing the connection.", null); - if (msg != null) { + return; + } + + if (!CheckParametersForClose (code, null, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null);