I've got a problem that when I send messages from Server to client they don't arrive at the client in their original order. I've got a test function here:
public async Task Hello(string group)
{
await Groups.Add(Context.ConnectionId, group);
await Clients.Group("grp1").Hello("grp1");
await Clients.Group("grp2").Hello("grp2");
await Clients.All.Hello("all");
}
And on client:
var chanceHub = $.connection.chanceHub;
chanceHub.client.Hello = function (message) {
alert(message);
}
$.connection.hub.start().done(function () {
chanceHub.server.hello("grp1");
});
I expect to get 2 alerts in this order: "grp1" then "all" But I always get the message "all" first. Is there any way to solve this issue?
Each client connecting to a SignalR hub has a unique connection id. We can retrieve this using the Context.ConnectionId property of the hub context. Using this, we can send messages just to that particular client: By default, SignalR uses the ClaimTypes.NameIdentifier from the ClaimsPrincipal associated with the connection as the user identifier.
One client sends a 4-KB message to let the server broadcast to all clients. The billed message count is eight: one message from the service to the application server and three messages from the service to the clients. Each message is counted as two 2-KB messages. There are server connections and client connections with Azure SignalR Service.
This documentation isn't for the latest version of SignalR. Take a look at ASP.NET Core SignalR. This document provides an introduction to programming the server side of the ASP.NET SignalR Hubs API for SignalR version 2, with code samples demonstrating common options.
The query string that you get in this property is the one that was used with the HTTP request that established the SignalR connection. You can add query string parameters in the client by configuring the connection, which is a convenient way to pass data about the client from the client to the server.
It's an unresolved issue #3310 for this problem. The issue also describes a workaround Issue #3310
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With