You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A System.IO.Pipelines adapter API over System.Net.WebSockets
10
-
11
9
# Usage
12
10
13
11
```csharp
@@ -20,27 +18,35 @@ using IWebSocketPipe pipe = WebSocketPipe.Create(client, closeWhenCompleted: tru
20
18
21
19
// Start the pipe before hooking up the processing
22
20
varrun=pipe.RunAsync();
21
+
```
23
22
24
-
// Wait for completion of processing code
25
-
awaitTask.WhenAny(
26
-
ReadIncoming(pipe.Input),
27
-
SendOutgoing(pipe.Output));
23
+
The `IWebSocketPipe` interface extends [IDuplexPipe](https://docs.microsoft.com/en-us/dotnet/api/system.io.pipelines.iduplexpipe?view=dotnet-plat-ext-5.0),
24
+
exposing `Input` and `Output` properties that can be used to
25
+
read incoming messages and write outgoing ones.
26
+
27
+
For example, to read incoming data and write it to the console,
28
+
we could write the following code:
28
29
29
-
// When the processing completes, the overall pipe run will also complete
30
-
awaitrun;
30
+
```csharp
31
+
awaitReadIncoming(pipe.Input);
31
32
32
-
// Reads incoming data and writes to the console
33
33
asyncTaskReadIncoming(PipeReaderreader)
34
34
{
35
35
while (awaitreader.ReadAsync() isvarresult&&!result.IsCompleted)
// Start the pipe before hooking up the processing
17
+
varrun=pipe.RunAsync();
18
+
```
19
+
20
+
The `IWebSocketPipe` interface extends [IDuplexPipe](https://docs.microsoft.com/en-us/dotnet/api/system.io.pipelines.iduplexpipe?view=dotnet-plat-ext-5.0),
21
+
exposing `Input` and `Output` properties that can be used to
22
+
read incoming messages and write outgoing ones.
23
+
24
+
For example, to read incoming data and write it to the console,
25
+
we could write the following code:
26
+
27
+
```csharp
28
+
awaitReadIncoming(pipe.Input);
29
+
30
+
asyncTaskReadIncoming(PipeReaderreader)
31
+
{
32
+
while (awaitreader.ReadAsync() isvarresult&&!result.IsCompleted)
0 commit comments