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 (#1157)
  • Loading branch information
Shane32 authored Oct 20, 2024
1 parent f5b7b32 commit 5f2dc82
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 @@ -227,7 +227,9 @@ public Task CloseAsync(int eventId, string? description)
/// </remarks>
public virtual 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 5f2dc82

Please # to comment.