title: Sending SignalR message to the specific user problem. What I am doing wrong?
body: <p>First of all, when I am sending SignalR message to all clients, everything <strong>works fine</strong>, with:</p>
  <pre><code>public async Task SendMessage(GameStateModel game)
  {
      UpdateExistingGame(game);
  
      await Clients.All.SendAsync(&quot;ReceiveMessage&quot;, game); //todo: send only to users in current game
  }
  </code></pre>
  <p>and in my client:</p>
  <pre><code>public addGameStateListener = (): void =&gt; {
    this.hubConnection.on('ReceiveMessage', (message: GameState) =&gt; {
      if (message.gameId == this.game.gameState.gameId) {
        this.game.setGame(message);
      }
    });
  };
  </code></pre>
  <p><strong>Now, when I am trying to send it to the specific client</strong>, I am doing something like this:</p>
  <pre><code>public async Task SendMessage(GameStateModel game) //todo: SendMessageAndUpdateCachedGame(GameStateModel game)
  {
      UpdateExistingGame(game);
  
      await SendToUsersInGame(game);
  }
  
  private async Task SendToUsersInGame(GameStateModel game)
  {
      foreach (string user in game.PlayersNames)
      {
          if (!string.IsNullOrEmpty(user))
          {
              string id = await GetUserId(user);
              await Clients.User(id).SendAsync(&quot;ReceiveMessage&quot;, game);
          }
      }
  }
  
  private async Task&lt;string&gt; GetUserId(string user) //from auth DB
  {
      return await _userService.GetUserId(user);
  }
  </code></pre>
  <p>where client-side code is still the same:</p>
  <pre><code>public addGameStateListener = (): void =&gt; {
    this.hubConnection.on('ReceiveMessage', (message: GameState) =&gt; {
      if (message.gameId == this.game.gameState.gameId) {
        this.game.setGame(message);
      }
    });
  };
  </code></pre>
  <p><strong>NOTE</strong> please note, that <code>GetUserId</code> is retreiving user ID from the database, but it is the same as <code>Context.User.Identity.Name</code>.</p>
  <p>And I am not getting any notification at the client. The problem is, that in <a href="https://docs.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/mapping-users-to-connections#IUserIdProvider" rel="nofollow noreferrer">documentation</a> it is written, that in hub it supposed to be:</p>
  <pre><code>public class MyHub : Hub
  {
      public void Send(string userId, string message)
      {
          Clients.User(userId).send(message);
      }
  }
  </code></pre>
  <p>and it is very confusing, becaue there is no such method as a <code>Send(string message)</code>. What am I doing wrong?</p>
  <p><strong>UPDATE</strong> Based <a href="https://github.com/dotnet/aspnetcore/issues/17106#issuecomment-554080681" rel="nofollow noreferrer">on this GitHub answer</a>, when sending the individual message I tried:</p>
  <pre><code>foreach (string user in game.PlayersNames)
  {
      if (!string.IsNullOrEmpty(user))
      {
          string id = await GetUserId(user);
          await Clients.Client(Context.ConnectionId).SendAsync(&quot;ReceiveMessage&quot;, game);
      }
  }
  </code></pre>
  <p>So now the question is, how to get every user's individual <code>Context.ConnectionId</code>?</p>