locked
how a client can get hub connection id of specific client using signalR RRS feed

  • Question

  • User-1461245458 posted

    I am working on chat application, I am able to do broadcast message to all client,

    but I want to send message to any specific client. I can get all connected clients hub connection Id, but how can I identify which hub connection id is used for a particular client.

    So I want to store any unique data created at server side code with hub connection id when client logins. But I am not able to store any unique key which is in session from Controller to hub class.

    I am using MVC5. Please suggest me any solution for it.

    Monday, April 24, 2017 4:36 AM

All replies

  • User-707554951 posted


    Hi vinodkus,

    From your description, you  want to get client connection id to call the special client instead of broadcast all clients.

    As far as I know, You could use Context.ConnectionId in the Hub class scope, it means current client connection id.

    More details, please refer the API guides:

    https://docs.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/hubs-api-guide-server#how-to-call-client-methods-from-the-hub-class

    Best regards,

    Cathy

    Tuesday, April 25, 2017 8:02 AM
  • User-1461245458 posted

    Thanks Cathy for your response.

    Actually I find my solution with another way,

    Actually I had to pass any specific user information like userid at the time of login and make a connection with hub connection id. So that If I call any friend with userid then

    on the basis of userid I can get his hub connection id and can call him.

    But I have one issue how to check that some message came at specific client and message window will automatically open there.

    Tuesday, April 25, 2017 10:28 AM