File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public async Task RunAsync()
1616 var client = new ClientWebSocket ( ) ;
1717
1818 await client . ConnectAsync ( server . Uri , CancellationToken . None ) ;
19- using var pipe = WebSocketPipe . Create ( client , closeWhenCompleted : true ) ;
19+ using var pipe = client . CreatePipe ( closeWhenCompleted : true ) ;
2020
2121 var read = Task . Run ( async ( ) =>
2222 {
Original file line number Diff line number Diff line change 1+ using System . ComponentModel ;
2+ using System . IO . Pipelines ;
3+ using Devlooped . Net ;
4+
5+ namespace System . Net . WebSockets ;
6+
7+ /// <summary>
8+ /// Provides the <see cref="CreatePipe"/> extension method for
9+ /// reading/writing to a <see cref="WebSocket"/> using the <see cref="IDuplexPipe"/> (and
10+ /// <see cref="IWebSocketPipe"/>) API.
11+ /// API.
12+ /// </summary>
13+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
14+ public static class WebSocketExtensions
15+ {
16+ /// <summary>
17+ /// Creates a <see cref="IWebSocketPipe"/> over the given <paramref name="webSocket"/>.
18+ /// </summary>
19+ /// <param name="webSocket">The <see cref="WebSocket"/> to adapt.</param>
20+ /// <param name="closeWhenCompleted">Whether to close the <paramref name="webSocket"/> when
21+ /// either the <see cref="IDuplexPipe.Input"/> or <see cref="IDuplexPipe.Output"/> is
22+ /// completed, or when <see cref="IWebSocketPipe.CompleteAsync"/> is invoked.</param>
23+ public static IWebSocketPipe CreatePipe ( this WebSocket webSocket , bool closeWhenCompleted = false )
24+ => WebSocketPipe . Create ( webSocket , closeWhenCompleted ? new WebSocketPipeOptions { CloseWhenCompleted = true } : WebSocketPipeOptions . Default ) ;
25+ }
26+
You can’t perform that action at this time.
0 commit comments