Scenario: I am waiting for webhook to hit my controller endpoint in .Net Core thereby confirming a payment by the customer to a third party. Ideally I would like this controller to trigger a message I send specifically to the customer who paid.
Problem: From what I'm reading I cannot call a hub method (SignalR) from my controller unless I intend to send to all clients. While my hub is tracking users via a dictionary of unique ids, I'm assuming that injecting a hub context as stated here will create a new instance of the hub without access to the existing ids in the hub that's running. Are there any other options for pushing a message to a specific client after receiving the webhook confirmation to my controller?
Looks like the solution for me is to create the payment through the hub (instead of a normal rest API) and pass the connectionId (The hub has a dictionary of userId and connectionId) for the client as information to be passed back by the third party webhook. This way when I receive the webhook call I also get the connectionId to reference when I call the hub service like this:
await _hubContext.Clients.Client(connectionID).SendAsync("CompletePayment", transactionId);