Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get SignalR user connection id out side the hub class?

I am using SignalR in my ASP.NET web application. Here I am calling client from outside to hub class using IHubContext. I need to get the current user's connection ID in order to send messages to the current user only. How can I get the connection ID on the client side?

like image 442
selvakumar Avatar asked Oct 18 '13 10:10

selvakumar


People also ask

How do you get SignalR user connection ID outside the Hub class?

For a . NET Client it is on the Connection object, inherited by HubConnection . Show activity on this post. There's another way also, you can get connection id into your controller from hub by invoking a method of hub and you can return the required ID from there.

What is Hub class SignalR?

The Context objectThe Hub class includes a Context property that contains the following properties with information about the connection: Property. Description. ConnectionId. Gets the unique ID for the connection, assigned by SignalR.


1 Answers

Yep. You can use $.connection.hub.id.

like image 188
Ruchira Avatar answered Oct 02 '22 12:10

Ruchira