✨ Websocket Server.

Signed-off-by: 秋雨落 <i@rain.cx>
This commit is contained in:
秋雨落
2023-09-12 12:14:54 +08:00
parent 2cfc2e65ea
commit d952b88bc1
2 changed files with 16 additions and 0 deletions
+4
View File
@@ -33,4 +33,8 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Web\" />
</ItemGroup>
</Project>
+12
View File
@@ -22,5 +22,17 @@ public class Startup
public void Configure(IApplicationBuilder app)
{
app.UseWebSockets();
app.Use(async (context, next) =>
{
if (context.WebSockets.IsWebSocketRequest)
{
await context.WebSockets.AcceptWebSocketAsync();
Logger.Info("Got WebSocket connection from {Ip}:{Port}", context.Connection.RemoteIpAddress?.ToString(), context.Connection.RemotePort);
}
await next(context);
});
}
}