CodeDemen
CodeDemen

Reputation: 1971

SignalR how to preserve message order from server to client

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?

Upvotes: 7

Views: 1271

Answers (1)

Espen Burud
Espen Burud

Reputation: 1881

It's an unresolved issue #3310 for this problem. The issue also describes a workaround Issue #3310

Upvotes: 5

Related Questions