问题
Does socket.io guarantee that on() callbacks will be called in the same order that the messages were emitted?
回答1:
Node.js is a single event loop so yes.
But you have another problem, think about the latency between you and your clients, if two clients sent their messages, the first message that came to the server will be handled first, so if the first client emitted his message but he had a higher latency to the server from the second client (which sent his message after the first client), then it's probably be the second client message that will be handled first
来源:https://stackoverflow.com/questions/14933868/message-ordering-in-socket-io