Get connectionId outside of Hub, SignalR

asp.net-mvc, signalr

Solution

You could implement IConnected/IDisconnect on the Hub and manually keep track of clients for example in a database, then pull back the list when required. The example below is from the SignalR Wiki

public class Status : Hub, IDisconnect, IConnected
{
    public Task Disconnect()
    {
        return Clients.leave(Context.ConnectionId, DateTime.Now.ToString());
    }

    public Task Connect()
    {
        return Clients.joined(Context.ConnectionId, DateTime.Now.ToString());
    }

    public Task Reconnect(IEnumerable<string> groups)
    {
        return Clients.rejoined(Context.ConnectionId, DateTime.Now.ToString());
    }
}

Problem

How do I get the clients connectionId/clientId outside of the Hub?.. I have managed to do the following: ``` var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>(); ``` But in that context-object there is no such thing as a `clientId`.

Original source