Reputation: 339
How would I communicate between two separate hubs?
So Hub1 is my ChatHub for Support Agents and Hub2 is my Hub for customers. Support agents have logins, customers have a form they fill out which creates a user and so on. But how can I pass the user created from Hub2 to Hub1 for all the users who have a Hub1(Support Agents) or is there some better way to do this?
Would I need to handle it all in Hub1 with some logic for differentiating between customers and agents?
May not be possible since the Hubs aren't static they are created per user right?
The problem with doing it all in one Hub is after the form is filled out it sends them to another page so they get a new connectionId and they have no Context.User.Identity.Name so there is no way to grab them again since I don't know their information from the new page.
Upvotes: 2
Views: 1253
Reputation: 10824
You can use GlobalHost.ConnectionManager for communicating between Hubs:
var ctx = GlobalHost.ConnectionManager.GetHubContext<HubName>();
ctx.Clients.All.methodName(parameter);
Upvotes: 1