Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions src/Transports.Subscriptions.WebSockets/WebSocketReaderPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,23 @@ public void LinkTo(ITargetBlock<OperationMessage> target)

public async Task Complete(WebSocketCloseStatus closeStatus, string statusDescription)
{
if (_socket.State != WebSocketState.Closed && _socket.State != WebSocketState.CloseSent)
if (_socket.State != WebSocketState.Closed && _socket.State != WebSocketState.CloseSent)
try
{
if (closeStatus == WebSocketCloseStatus.NormalClosure)
{
// If nothing went wrong, close connection with handshakes.
await _socket.CloseOutputAsync(
closeStatus,
statusDescription,
CancellationToken.None);
}
else
{
// Something went wrong, so don't wait for answer from the other side, just close the connection.
await _socket.CloseAsync(
closeStatus,
statusDescription,
CancellationToken.None);
}

_startBlock.Complete();
if (closeStatus == WebSocketCloseStatus.NormalClosure)
await _socket.CloseAsync(
closeStatus,
statusDescription,
CancellationToken.None);
else
await _socket.CloseOutputAsync(
closeStatus,
statusDescription,
CancellationToken.None);
}
finally
{
_startBlock.Complete();
}
}

Expand Down