Skip to content

Commit

Permalink
Discard messages sent after the close message has been posted to the …
Browse files Browse the repository at this point in the history
…queue
  • Loading branch information
Shane32 committed Oct 7, 2024
1 parent a84c553 commit 6f7d462
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Transports.AspNetCore/WebSockets/WebSocketConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ public Task CloseAsync(int eventId, string? description)
/// </remarks>
public Task SendMessageAsync(OperationMessage message)
{
_pump.Post(new Message { OperationMessage = message });
// Messages posted after requesting the connection be closed will be discarded.
if (!_closeRequested)
_pump.Post(new Message { OperationMessage = message });
return Task.CompletedTask;
}

Expand Down

0 comments on commit 6f7d462

Please # to comment.