| | 1 | | using System.Net.WebSockets; |
| | 2 | | using NostrSure.Infrastructure.Client.Abstractions; |
| | 3 | |
|
| | 4 | | namespace NostrSure.Infrastructure.Client.Implementation; |
| | 5 | |
|
| | 6 | | /// <summary> |
| | 7 | | /// Wrapper for ClientWebSocket to implement IClientWebSocket |
| | 8 | | /// </summary> |
| | 9 | | public sealed class ClientWebSocketWrapper : IClientWebSocket |
| | 10 | | { |
| | 11 | | private readonly ClientWebSocket _webSocket; |
| | 12 | |
|
| 1 | 13 | | public ClientWebSocketWrapper(ClientWebSocket webSocket) |
| 1 | 14 | | { |
| 1 | 15 | | _webSocket = webSocket ?? throw new ArgumentNullException(nameof(webSocket)); |
| 1 | 16 | | } |
| | 17 | |
|
| 0 | 18 | | public WebSocketState State => _webSocket.State; |
| | 19 | |
|
| | 20 | | public Task ConnectAsync(Uri uri, CancellationToken cancellationToken) |
| 0 | 21 | | { |
| 0 | 22 | | return _webSocket.ConnectAsync(uri, cancellationToken); |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | public Task CloseAsync(WebSocketCloseStatus closeStatus, string? statusDescription, CancellationToken cancellationTo |
| 0 | 26 | | { |
| 0 | 27 | | return _webSocket.CloseAsync(closeStatus, statusDescription, cancellationToken); |
| 0 | 28 | | } |
| | 29 | |
|
| | 30 | | public void Dispose() |
| 0 | 31 | | { |
| 0 | 32 | | _webSocket.Dispose(); |
| 0 | 33 | | } |
| | 34 | | } |