Reputation: 1317
I'm new to SignalR and have some questions about using it correctly in certain scenarios
For my application I'm using signalR to communicate to a client the status of an operation they submitted, while they wait for the final response. My code is structured as such:
I've been able to achieve all this. But I had to setup a new type using GetHubContext to be able to call my signal method, because I can't work with the Hub object directly. Doing this doesn't allow me to send the signal a specific user because it's not known to the service layer, I'm only able to broadcast to all.
What pattern should I be using to achieve this? For my current setup it seems I would need to setup incoming connections with a group equal to their connectionId, communicate the connectionId to the various layers, and send a signal to that specific "group" as needed. Is this the best setup?
Upvotes: 1
Views: 304
Reputation: 2208
I'd say that the answer is yes, that seems to be the best setup. Please, read the answer to this question, I'd say this will help you with an example.
SignalR - Sending a message to a specific user using (IUserIdProvider) *NEW 2.0.0*
[Edit]
The key point is the mapping between the connectionId and the users. In your case it will depend on your implementation, I can't tell you the best way to handle it...
Also, a very good answer there talks about SendToUser tests here:
It lookjs like something you could use in your solution. [Edit]
I hope it helps.
Upvotes: 1