是否以FIFO顺序发送sockets.io消息?

时间:2018-05-28 09:40:18

标签: javascript events socket.io

在客户端接收多条消息时,我可以依赖它的发送顺序吗?

例如,请考虑以下代码:

服务器端

let io = require('socket.io')(80);

io.on('connection', (socket) => {
    socket.emit('myevent', 'First event');
    socket.emit('myevent', 'Second event');
})

客户端

let socket = new io()
    .on('myevent', (msg) => {
        console.log(msg);
    })

我可以确定邮件会以正确的顺序记录,我的意思是:

First event
Second event

0 个答案:

没有答案