mirror of
https://github.com/yawaflua/WebSockets.git
synced 2025-12-10 04:19:33 +02:00
Adds example of using preConnectionHandler, create OnConnectionHandler(preConnectionHandler), use WebSocketOptions for provides data
This commit is contained in:
@@ -8,12 +8,14 @@ namespace yawaflua.WebSockets;
|
||||
|
||||
public static class ServiceBindings
|
||||
{
|
||||
public static IServiceCollection SettingUpWebSockets(this IServiceCollection isc, Action<WebSocketOptions>? socketOptions = null)
|
||||
public static IServiceCollection SettingUpWebSockets(this IServiceCollection isc, WebSocketConfig? socketOptions = null)
|
||||
{
|
||||
isc.AddSingleton<WebSocketRouter>();
|
||||
if (socketOptions != null) isc.AddSingleton(socketOptions);
|
||||
if (isc.All(k => k.ServiceType != typeof(WebSocketConfig)))
|
||||
isc.AddSingleton(new WebSocketConfig());
|
||||
isc.AddScoped<IWebSocketManager, WebSocketManager>();
|
||||
isc.AddSingleton<WebSocketMiddleware>();
|
||||
isc.Configure("WebSocketOptions", socketOptions);
|
||||
return isc;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user