Skip to content

Commit 4299fca

Browse files
committed
[Modify] Throw exception
1 parent 222077a commit 4299fca

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

websocket-sharp/WebSocket.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3106,10 +3106,21 @@ public void CloseAsync (CloseStatusCode code, string reason)
31063106
/// </remarks>
31073107
public void Connect ()
31083108
{
3109-
string msg;
3110-
if (!checkIfAvailable (true, false, true, false, false, true, out msg)) {
3111-
_logger.Error (msg);
3112-
error ("An error has occurred in connecting.", null);
3109+
if (!_client) {
3110+
var msg = "This instance is not a client.";
3111+
throw new InvalidOperationException (msg);
3112+
}
3113+
3114+
if (_readyState == WebSocketState.Open) {
3115+
var msg = "The connection has already been established.";
3116+
_logger.Warn (msg);
3117+
3118+
return;
3119+
}
3120+
3121+
if (_readyState == WebSocketState.Closing) {
3122+
var msg = "The close process is in progress.";
3123+
_logger.Warn (msg);
31133124

31143125
return;
31153126
}

0 commit comments

Comments
 (0)