Iam using SignalR to create my first chat App every thing goes well but the problem is when I want to send message from one client to another not to all clients the question is how can I target just one client by its connection id or user name ?
this is My server side code (Hub class) i just want to know how to handel these methods in js to specify any client i want to send message to
public async Task SendMessageUser(string user, string message)
{
// here you need to set a specifc the user
await Clients.User("username").SendAsync("ReceiveMessage", user, message);
}
public async Task SendMessageToClient(string user, string receiverConnectionId, string message)
{
await Clients.Client(receiverConnectionId).SendAsync("ReceiveMessage", user, message);
}
public async Task SendMessageUsers(string user, string message)
{
// here you need to set the list of Users
await Clients.Users(new string[] { "myUser", "myUser2" }).SendAsync("ReceiveMessage", user, message);
}