Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!