Adds onOpenHandler

This commit is contained in:
Dmitri Shimanski
2025-03-29 04:22:57 +03:00
parent 2af82e6fc5
commit 4a22cf3337
3 changed files with 22 additions and 3 deletions

View File

@@ -8,11 +8,12 @@ namespace yawaflua.WebSockets;
public static class ServiceBindings
{
public static IServiceCollection SettingUpWebSockets(this IServiceCollection isc)
public static IServiceCollection SettingUpWebSockets(this IServiceCollection isc, Action<WebSocketOptions>? socketOptions = null)
{
isc.AddSingleton<WebSocketRouter>();
isc.AddScoped<IWebSocketManager, WebSocketManager>();
isc.AddSingleton<WebSocketMiddleware>();
isc.Configure("WebSocketOptions", socketOptions);
return isc;
}