locked
SignalR - Synchronous communication between two hub client, via one hub RRS feed

  • Question

  • User-2136701028 posted

    Hello,

    I have two clients connecting to one hub using SignalR.

    My requirement is as follows:
    Client A has made a connection with the hub.
    A request comes to the hub from Client B, and that request needs to be sent to Client A from the hub.
    And a response needs to be returned from Client A to the hub and that response needs to be sent back to Client B.

    All this needs to happen synchronously.
    Is it possible to achieve this?

    Thank you in advance.

    Wednesday, June 22, 2016 6:28 AM

Answers

  • User61956409 posted

    Hi thusithagh,

    Welcome to ASP.NET forum.

    Each client connecting to a hub passes a unique connection id, if you’d like to broadcast message between two clients (one-to-one), you could refer to the following sample code to send a message to a specific user.

    public class MyHub : Hub
    {
        public void Send(string userId, string message)
        {
            Clients.User(userId).send(message);
        }
    }
    

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 23, 2016 7:43 AM