|
2 | 2 |
|
3 | 3 | namespace Cnblogs.DashScope.Core.Internals;
|
4 | 4 |
|
5 |
| -internal sealed class ClientWebSocketWrapper(ClientWebSocket socket) : IClientWebSocket |
| 5 | +internal sealed class ClientWebSocketWrapper : IClientWebSocket |
6 | 6 | {
|
| 7 | + private readonly ClientWebSocket _socket; |
| 8 | + |
| 9 | + public ClientWebSocketWrapper(ClientWebSocket socket) |
| 10 | + { |
| 11 | + _socket = socket; |
| 12 | + } |
| 13 | + |
7 | 14 | /// <inheritdoc />
|
8 | 15 | public void Dispose()
|
9 | 16 | {
|
10 |
| - socket.Dispose(); |
| 17 | + _socket.Dispose(); |
11 | 18 | }
|
12 | 19 |
|
13 | 20 | /// <inheritdoc />
|
14 |
| - public ClientWebSocketOptions Options => socket.Options; |
| 21 | + public ClientWebSocketOptions Options => _socket.Options; |
15 | 22 |
|
16 | 23 | /// <inheritdoc />
|
17 |
| - public WebSocketCloseStatus? CloseStatus => socket.CloseStatus; |
| 24 | + public WebSocketCloseStatus? CloseStatus => _socket.CloseStatus; |
18 | 25 |
|
19 | 26 | /// <inheritdoc />
|
20 |
| - public Task ConnectAsync(Uri uri, CancellationToken cancellation) => socket.ConnectAsync(uri, cancellation); |
| 27 | + public Task ConnectAsync(Uri uri, CancellationToken cancellation) => _socket.ConnectAsync(uri, cancellation); |
21 | 28 |
|
22 | 29 | /// <inheritdoc />
|
23 | 30 | public Task SendAsync(
|
24 | 31 | ArraySegment<byte> buffer,
|
25 | 32 | WebSocketMessageType messageType,
|
26 | 33 | bool endOfMessage,
|
27 | 34 | CancellationToken cancellationToken)
|
28 |
| - => socket.SendAsync(buffer, messageType, endOfMessage, cancellationToken); |
| 35 | + => _socket.SendAsync(buffer, messageType, endOfMessage, cancellationToken); |
29 | 36 |
|
30 | 37 | /// <inheritdoc />
|
31 | 38 | public Task<WebSocketReceiveResult> ReceiveAsync(ArraySegment<byte> buffer, CancellationToken cancellationToken)
|
32 |
| - => socket.ReceiveAsync(buffer, cancellationToken); |
| 39 | + => _socket.ReceiveAsync(buffer, cancellationToken); |
33 | 40 |
|
34 | 41 | /// <inheritdoc />
|
35 | 42 | public Task CloseAsync(
|
36 | 43 | WebSocketCloseStatus closeStatus,
|
37 | 44 | string? statusDescription,
|
38 | 45 | CancellationToken cancellationToken)
|
39 |
| - => socket.CloseAsync(closeStatus, statusDescription, cancellationToken); |
| 46 | + => _socket.CloseAsync(closeStatus, statusDescription, cancellationToken); |
40 | 47 | }
|
0 commit comments