Skip to content

Commit 9dee954

Browse files
committed
[Modify] Replace it
1 parent 430962f commit 9dee954

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

websocket-sharp/WebSocket.cs

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,29 @@ private bool checkIfAvailable (
797797
bool connecting, bool open, bool closing, bool closed, out string message
798798
)
799799
{
800-
return checkIfAvailable (true, true, connecting, open, closing, closed, out message);
800+
message = null;
801+
802+
if (!connecting && _readyState == WebSocketState.Connecting) {
803+
message = "This operation isn't available in: connecting";
804+
return false;
805+
}
806+
807+
if (!open && _readyState == WebSocketState.Open) {
808+
message = "This operation isn't available in: open";
809+
return false;
810+
}
811+
812+
if (!closing && _readyState == WebSocketState.Closing) {
813+
message = "This operation isn't available in: closing";
814+
return false;
815+
}
816+
817+
if (!closed && _readyState == WebSocketState.Closed) {
818+
message = "This operation isn't available in: closed";
819+
return false;
820+
}
821+
822+
return true;
801823
}
802824

803825
private bool checkIfAvailable (
@@ -822,27 +844,7 @@ out string message
822844
return false;
823845
}
824846

825-
if (!connecting && _readyState == WebSocketState.Connecting) {
826-
message = "This operation isn't available in: connecting";
827-
return false;
828-
}
829-
830-
if (!open && _readyState == WebSocketState.Open) {
831-
message = "This operation isn't available in: open";
832-
return false;
833-
}
834-
835-
if (!closing && _readyState == WebSocketState.Closing) {
836-
message = "This operation isn't available in: closing";
837-
return false;
838-
}
839-
840-
if (!closed && _readyState == WebSocketState.Closed) {
841-
message = "This operation isn't available in: closed";
842-
return false;
843-
}
844-
845-
return true;
847+
return checkIfAvailable (connecting, open, closing, closed, out message);
846848
}
847849

848850
private bool checkReceivedFrame (WebSocketFrame frame, out string message)

0 commit comments

Comments
 (0)