SignalR ConnectionManager Singleton
Hey, does anyone have any experience creating a ConnectionManager for SignalR? Right now I feel like I have to create my connection and all immediately in the program.cs (I am new to signalR). But I don't like that at all. However if you create a singleton of the connection, does it subscribe still? where do you put all those events? The same place you run start.async()?
4 Replies
create a singleton service and use a thread-safe collection to store all of your connections
Yes, I think it's the subscription thing i'm more confused with, like wheere do i put all those connection.On<>?
you mean how to handle connection when user connect successfully to your hub?
you can override OnConnectedAsync and OnDisconnectedAsync
I'm talking from the client's perspective