Skip to content

Commit 9b1941b

Browse files
authored
Remove Nowin WebSocket sample (#34221)
1 parent 017f4f0 commit 9b1941b

File tree

1 file changed

+0
-52
lines changed

1 file changed

+0
-52
lines changed

aspnetcore/fundamentals/owin.md

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -90,58 +90,6 @@ app.UseOwin(pipeline =>
9090
});
9191
```
9292

93-
<a name="hosting-on-owin"></a>
94-
95-
## Run ASP.NET Core on an OWIN-based server and use its WebSockets support
96-
97-
Another example of how OWIN-based servers' features can be leveraged by ASP.NET Core is access to features like WebSockets. The .NET OWIN web server used in the previous example has support for WebSockets built in, which can be leveraged by an ASP.NET Core application. The example below shows a simple web app that supports WebSockets and echoes back everything sent to the server through WebSockets.
98-
99-
```csharp
100-
public class Startup
101-
{
102-
public void Configure(IApplicationBuilder app)
103-
{
104-
app.Use(async (context, next) =>
105-
{
106-
if (context.WebSockets.IsWebSocketRequest)
107-
{
108-
WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync();
109-
await EchoWebSocket(webSocket);
110-
}
111-
else
112-
{
113-
await next();
114-
}
115-
});
116-
117-
app.Run(context =>
118-
{
119-
return context.Response.WriteAsync("Hello World");
120-
});
121-
}
122-
123-
private async Task EchoWebSocket(WebSocket webSocket)
124-
{
125-
byte[] buffer = new byte[1024];
126-
WebSocketReceiveResult received = await webSocket.ReceiveAsync(
127-
new ArraySegment<byte>(buffer), CancellationToken.None);
128-
129-
while (!webSocket.CloseStatus.HasValue)
130-
{
131-
// Echo anything we receive
132-
await webSocket.SendAsync(new ArraySegment<byte>(buffer, 0, received.Count),
133-
received.MessageType, received.EndOfMessage, CancellationToken.None);
134-
135-
received = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer),
136-
CancellationToken.None);
137-
}
138-
139-
await webSocket.CloseAsync(webSocket.CloseStatus.Value,
140-
webSocket.CloseStatusDescription, CancellationToken.None);
141-
}
142-
}
143-
```
144-
14593
## OWIN environment
14694

14795
You can construct an OWIN environment using the `HttpContext`.

0 commit comments

Comments
 (0)