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
Any reason to set the WebSocketHandler service as a Singleton and WebSocketConnectionManager service as transient?
From my point of view WebSocketConnectionManager should be a Singleton and WebSocketHandler a transient or scoped service as the entry point for the websocket is the handler, we don't have to keep it as a singleton but allow other scoped DI to be used inside the handler (like for EF #68 - #72)
To be able to keep mapped route to specific handler, I tried to give to the middleware the handler type (like app.MapWebSocketManager<ConnectionHandler>("/connection");) and calling var webSocketHandler = (WebSocketHandler)serviceProvider.GetService(_handlerType); directly in the middleware Invoke function.
This is working fine but I don't know if it's the best way to do runtime dependency injection setup.
Regards
The text was updated successfully, but these errors were encountered:
Hi,
Any reason to set the WebSocketHandler service as a Singleton and WebSocketConnectionManager service as transient?
From my point of view WebSocketConnectionManager should be a Singleton and WebSocketHandler a transient or scoped service as the entry point for the websocket is the handler, we don't have to keep it as a singleton but allow other scoped DI to be used inside the handler (like for EF #68 - #72)
To be able to keep mapped route to specific handler, I tried to give to the middleware the handler type (like
app.MapWebSocketManager<ConnectionHandler>("/connection");
) and callingvar webSocketHandler = (WebSocketHandler)serviceProvider.GetService(_handlerType);
directly in the middlewareInvoke
function.This is working fine but I don't know if it's the best way to do runtime dependency injection setup.
Regards
The text was updated successfully, but these errors were encountered: