[Modify] Add a check

This commit is contained in:
sta 2016-03-26 16:25:48 +09:00
parent 5bf96cf7ff
commit 49b09654f6

View File

@ -2810,7 +2810,6 @@ namespace WebSocketSharp
/// </param>
public void SetCredentials (string username, string password, bool preAuth)
{
lock (_forConn) {
string msg;
if (!checkIfAvailable (true, false, true, false, false, true, out msg)) {
_logger.Error (msg);
@ -2819,6 +2818,14 @@ namespace WebSocketSharp
return;
}
lock (_forConn) {
if (!checkIfAvailable (true, false, false, true, out msg)) {
_logger.Error (msg);
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;