From 296ede4c33e4412b3a476f4985db7665982e79ae Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Aug 2016 16:59:55 +0900 Subject: [PATCH] [Modify] Move it out --- websocket-sharp/WebSocket.cs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 19f68b46..4aebd11f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2818,32 +2818,34 @@ namespace WebSocketSharp return; } - lock (_forState) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!username.IsNullOrEmpty ()) { + if (username.Contains (':') || !username.IsText ()) { + _logger.Error ("'username' contains an invalid character."); error ("An error has occurred in setting the credentials.", null); return; } - if (username.IsNullOrEmpty ()) { - _logger.Warn ("The credentials are set back to the default."); - _credentials = null; - _preAuth = false; + if (!password.IsNullOrEmpty () && !password.IsText ()) { + _logger.Error ("'password' contains an invalid character."); + error ("An error has occurred in setting the credentials.", null); return; } + } - if (username.Contains (':') || !username.IsText ()) { - _logger.Error ("'username' contains an invalid character."); + lock (_forState) { + if (!checkIfAvailable (true, false, false, true, out msg)) { + _logger.Error (msg); error ("An error has occurred in setting the credentials.", null); return; } - if (!password.IsNullOrEmpty () && !password.IsText ()) { - _logger.Error ("'password' contains an invalid character."); - error ("An error has occurred in setting the credentials.", null); + if (username.IsNullOrEmpty ()) { + _logger.Warn ("The credentials are set back to the default."); + _credentials = null; + _preAuth = false; return; }