Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
Send Message to Specific user using Azure SignalR

Using Azure SignalR (not .Net Core SignalR), Is Clients.Users.SendAsync supported to send message to specific user?

[Authorize]
public class ChatHub : Hub
{
    public async Task OnNewMessage(string userId, string message)
    {
        await Clients.Users(userId) 
             //Does Azure SignalR supports sending message to specific user,
             // the way .Net Core SignalR does it
            .SendAsync("OnNewMessage", userId, message);
    }
}

If yes, How Asp.Net Identity Claims Principal gets passed to Azure SignalR?

Edit: 18th June 2021

Responses below are not addressing the concerns. Sorry but I had already followed documentation for customizing UserIdBasedProvider etc. I want to stress out that -

This question is pertaining to how SignalR handles .Users(<*some-user-id*>).Send();

Ideally we do .Client(<connection id>).Send() to send message to specific user. But for this architecture we must store userId and connectionId ourselves in DB etc.

.User(userId).Send() works perfectly with .Net Core SignalR. So I believe SignalR SDK must have been keeping map of each connection Id and user Id in memory.

Does Azure SignalR internally keeps track of UserId, Connection Id mapping and sends the message?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can achieve this by Implementing your customized IUserIdProvider like this and register it as an singleton.

 public class UserIdProvider : IUserIdProvider
    {
        public string GetUserId(HubConnectionContext connection)
        {
            return connection.User.FindFirst(ClaimConstants.PreferredUserName).Value;
        }
    }

Related Reference and Github

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda