From 80efd30b93465f2eb80dc15c6d0aa2838f6beb02 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Mar 2016 15:24:08 +0900 Subject: [PATCH] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 38 +++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5ff73803..268716e1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2814,25 +2814,31 @@ namespace WebSocketSharp public void SetCredentials (string username, string password, bool preAuth) { lock (_forConn) { - var msg = checkIfAvailable (true, false, true, false, false, true); - if (msg == null) { - if (username.IsNullOrEmpty ()) { - _credentials = null; - _preAuth = false; - _logger.Warn ("The credentials were set back to the default."); + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { + _logger.Error (msg); + error ("An error has occurred in setting the credentials.", null); - return; - } - - msg = username.Contains (':') || !username.IsText () - ? "'username' contains an invalid character." - : !password.IsNullOrEmpty () && !password.IsText () - ? "'password' contains an invalid character." - : null; + return; } - if (msg != null) { - _logger.Error (msg); + if (username.IsNullOrEmpty ()) { + _credentials = null; + _preAuth = false; + _logger.Warn ("The credentials were set back to the default."); + + return; + } + + if (username.Contains (':') || !username.IsText ()) { + _logger.Error ("'username' contains an invalid character."); + 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); return;