I'm new and experimenting SignalR, so go easy.
I know we can access clients of all sorts within the hub class itself by using
Clients.All
Clients.Others
Clients.Group
Clients.Caller
Clients.Client
However, whenever I try to access clients from other classes by the hub context
var hubContext = GlobalHost.ConnectionManager.GetHubContext<NotificationHub>();
hubContext
only gives me access to
hubContext.Clients.All
hubContext.Clients.Group
hubContext.Clients.Client
There are two questions I'd like some answers to.
- How can I access Clients.Others/Caller from the
hubContext
? - How can I retrieve my mapped connectionlist in the hub from hubContext so that I can iterate through the list of connection ids to be passed over to Clients.Client() method?
Assuming my mapped user lists as below:
public static List<UserConnection> ActiveUsers = new List<UserConnection>();
//onConnected will add users of UserConnection class into ActiveUsers list
class UserConnection
{
public string UserName { set; get; }
public string ConnectionID { set; get; }
}