When an user join the game, you just add it to a group:
public Task JoinRoom(string roomName)
{
return Groups.Add(Context.ConnectionId, roomName);
}
Just make sure that you have one group per game (ie one roomName per game).
Then you can communicate with all the users in the same group (in our case, roomName)
Clients.Group(roomName).GameStatusUpdated(status)
To leave a group:
public Task LeaveRoom(string roomName)
{
return Groups.Remove(Context.ConnectionId, roomName);
}
Groups are not the only solution. You can use in-memory mapping or database mapping. Take a look here.