Skip to content

Commit 1cbf76c

Browse files
committed
📝 Minimal wording/simplification for server scenario
1 parent e26aecf commit 1cbf76c

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

readme.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ await pipe.CompleteAsync(WebSocketCloseStatus.NormalClosure, "Done processing");
9090

9191
Specifying a close status will always close the underlying socket.
9292

93-
You can also use it on the server. This example is basically taken from
94-
the documentation on [WebSockets in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/websockets?view=aspnetcore-5.0#configure-the-middleware)
95-
and adapted to use a `WebSocketPipe` to read/write to the client:
93+
The `WebSocketPipe` can also be used on the server. The following example is basically
94+
taken from the documentation on [WebSockets in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/websockets?view=aspnetcore-5.0#configure-the-middleware)
95+
and adapted to use a `WebSocketPipe` to echo messages to the client:
9696

9797
```csharp
9898
app.Use(async (context, next) =>
@@ -101,9 +101,7 @@ app.Use(async (context, next) =>
101101
{
102102
if (context.WebSockets.IsWebSocketRequest)
103103
{
104-
using var websocket = await context.WebSockets.AcceptWebSocketAsync(
105-
context.WebSockets.WebSocketRequestedProtocols.FirstOrDefault());
106-
104+
using var websocket = await context.WebSockets.AcceptWebSocketAsync();
107105
using var pipe = WebSocketPipe.Create(websocket, options);
108106
await Task.WhenAll(Echo(pipe), pipe.RunAsync(context.RequestAborted));
109107
}

0 commit comments

Comments
 (0)