You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should be the WebSocketConnectionManager registered as singleton instead of user defined WebSocketHandlers?
Imagine the situation where you want to resolve some resources in your WebSocketHandler which are dependent on the request context = so they differ per request.
I think the better implementation is:
public static IServiceCollection AddWebSocketManager(this IServiceCollection services)
{
services.AddSingleton<WebSocketConnectionManager>();
foreach (var type in Assembly.GetEntryAssembly().ExportedTypes)
{
if (type.GetTypeInfo().BaseType == typeof(WebSocketHandler))
{
services.AddScoped(type);
}
}
return services;
}
The text was updated successfully, but these errors were encountered:
Should be the
WebSocketConnectionManager
registered as singleton instead of user definedWebSocketHandlers
?Imagine the situation where you want to resolve some resources in your
WebSocketHandler
which are dependent on the request context = so they differ per request.I think the better implementation is:
The text was updated successfully, but these errors were encountered: