I use class Echo derived from PersistentConnection, and I want to send a message to certain connection:
var client = GlobalHost.ConnectionManager.GetConnectionContext<Echo>();
client.Connection.Broadcast(msg);
But I want to send it to specific connection ID. Do I have to create a group for every connection or start using Hubs, or there is a simpler way to select connection by ID, something like:
GetConnectionById(id).Send(msg);
?
Message can be sent to a specific connection ID, but the syntax is not same as what you specified in the question. Following snippet shows the syntax:
Source of my answer: SignalR wiki on Github
I think, you are aware that SignalR 1 Alpha is released. It is possible to send message to a specific client by its ID if you use this version. Following snippet shows it:
Here,
((Connection)connection).Identitygives connection ID of the requesting client.