简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM