1

I'm trying to restrict SignalR between two users. At this point in time it's ok if it's just one way connection from User A -> User B.

I'm using some of Microsoft's code and just thought I'd hard code the userId to see if I could get things working but no luck.

public void BroadcastShape(object state)
{
    // No need to send anything if our model hasn't changed
    if (_modelUpdated)
    {
         // This is how we can access the Clients property 
         // in a static hub method or outside of the hub entirely

         var userId = "b51xx-xxxxxx-xxxxxxx-xxxxx-xxx01b";
         _hubContext.Clients.User(userId).updateProduct()

         // _hubContext.Clients.AllExcept(_model.LastUpdatedBy).updateShape(_model);
         _modelUpdated = false;
    }
}

Any tips on other methods that I need to change from this documentation would be great: https://learn.microsoft.com/en-us/aspnet/signalr/overview/getting-started/tutorial-high-frequency-realtime-with-signalr

Davis Broda
  • 4,102
  • 5
  • 23
  • 37
Mike
  • 1,281
  • 3
  • 14
  • 41
  • 1
    Users don't connect to each other. They connect to the server. Are you trying to ask how to restrict the server so that only those two users can talk to it? – mason Jun 20 '17 at 18:04
  • Possible duplicate of [signalR - getting username](https://stackoverflow.com/questions/12130590/signalr-getting-username) – mason Jun 20 '17 at 18:40
  • Are you sure? In any case based on that post i still don't understand the following: If i have two separate aspnetusers logged in how on a theoretical level do i let signal r know that it's only those 2 client id's i want to associate? Like in that join method why do u need to include httpcontext.current.user.identity if signalr has its own client id? – Mike Jun 20 '17 at 19:23

0 Answers0