C
C#3y ago
Zerthz

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
FroH.LVT
FroH.LVT3y ago
create a singleton service and use a thread-safe collection to store all of your connections
Zerthz
ZerthzOP3y ago
Yes, I think it's the subscription thing i'm more confused with, like wheere do i put all those connection.On<>?
FroH.LVT
FroH.LVT3y ago
you mean how to handle connection when user connect successfully to your hub? you can override OnConnectedAsync and OnDisconnectedAsync
Zerthz
ZerthzOP3y ago
I'm talking from the client's perspective
Want results from more Discord servers?
Add your server