Skip to content

Commit

Permalink
throw exception when user tries to start receive when the websocket c…
Browse files Browse the repository at this point in the history
…onnection is not open
  • Loading branch information
kerryjiang committed Nov 9, 2024
1 parent 6a91a01 commit 77f7775
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/WebSocket4Net/WebSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ private void WriteHandshakeRequest(PipeWriter writer, string secKey)

public new void StartReceive()
{
if (State != WebSocketState.Open)
{
throw new InvalidOperationException($"You cannot call the method {nameof(StartReceive)} when the websocket connection is not open.");
}

base.StartReceive();
_packageHandlerMode = true;
}
Expand Down

0 comments on commit 77f7775

Please sign in to comment.