diff options
| author | Bond_009 <bond.009@outlook.com> | 2024-10-31 17:02:06 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2024-10-31 17:02:06 +0100 |
| commit | d2db7004024c6bbdd541a381c673f1e0b0aebfcb (patch) | |
| tree | 48d21b619b13c73fc85988d7c0b33a816b4f2c02 /Emby.Server.Implementations/HttpServer/WebSocketConnection.cs | |
| parent | 282784cbb6fe203b87a6f2c673454ac8d3da82fa (diff) | |
Always await instead of directly returning Task
https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/blob/master/AsyncGuidance.md#prefer-asyncawait-over-directly-returning-task
The performance impact is negligible (and it's me saying that!)
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/WebSocketConnection.cs')
| -rw-r--r-- | Emby.Server.Implementations/HttpServer/WebSocketConnection.cs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs index cb6f7e1d3..a720c86fb 100644 --- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs +++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs @@ -82,17 +82,17 @@ namespace Emby.Server.Implementations.HttpServer public WebSocketState State => _socket.State; /// <inheritdoc /> - public Task SendAsync(OutboundWebSocketMessage message, CancellationToken cancellationToken) + public async Task SendAsync(OutboundWebSocketMessage message, CancellationToken cancellationToken) { var json = JsonSerializer.SerializeToUtf8Bytes(message, _jsonOptions); - return _socket.SendAsync(json, WebSocketMessageType.Text, true, cancellationToken); + await _socket.SendAsync(json, WebSocketMessageType.Text, true, cancellationToken).ConfigureAwait(false); } /// <inheritdoc /> - public Task SendAsync<T>(OutboundWebSocketMessage<T> message, CancellationToken cancellationToken) + public async Task SendAsync<T>(OutboundWebSocketMessage<T> message, CancellationToken cancellationToken) { var json = JsonSerializer.SerializeToUtf8Bytes(message, _jsonOptions); - return _socket.SendAsync(json, WebSocketMessageType.Text, true, cancellationToken); + await _socket.SendAsync(json, WebSocketMessageType.Text, true, cancellationToken).ConfigureAwait(false); } /// <inheritdoc /> @@ -224,12 +224,12 @@ namespace Emby.Server.Implementations.HttpServer return ret; } - private Task SendKeepAliveResponse() + private async Task SendKeepAliveResponse() { LastKeepAliveDate = DateTime.UtcNow; - return SendAsync( + await SendAsync( new OutboundKeepAliveMessage(), - CancellationToken.None); + CancellationToken.None).ConfigureAwait(false); } /// <inheritdoc /> |
