Skip to content

Commit 77f7775

Browse files
committed
throw exception when user tries to start receive when the websocket connection is not open
1 parent 6a91a01 commit 77f7775

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/WebSocket4Net/WebSocket.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ private void WriteHandshakeRequest(PipeWriter writer, string secKey)
226226

227227
public new void StartReceive()
228228
{
229+
if (State != WebSocketState.Open)
230+
{
231+
throw new InvalidOperationException($"You cannot call the method {nameof(StartReceive)} when the websocket connection is not open.");
232+
}
233+
229234
base.StartReceive();
230235
_packageHandlerMode = true;
231236
}

0 commit comments

Comments
 (0)