When the user logs in on my site, they select from a dropdown which group they belong to. On the login postback, as they are logged in, I'd like to assign them to the correct SignalR group.
As per the documentation here, I can join it client-side via:
contosoChatHubProxy.server.joinGroup(groupName);
Is there a way to assign the group from the controller? I can call the Hub like:
var hub = new NotificationHub()
hub.JoinGroup(selectedGroup);
but the Context in the hub method is null. Is this possible, or am I approaching this problem incorrectly? Thankyou for any advice.
You shouldn't new up a hub like that; you can get the hub context and add a user to a group from external code like this: