How to be sure that message via socket.io has been received to the client?

后端 未结 3 1236
情深已故
情深已故 2020-12-24 08:03

How to check that message sent with socket.io library has been received to the client. Is there special method for it in socket.io?

Thanks for you

3条回答
  •  遥遥无期
    2020-12-24 08:27

    When you add a function as the last parameter of .send() or .emit() method calls, this function is called when the other party receives the message.

    socket.send('hi', function() {
        // if we are here, our salutation has been received by the other party.
    });
    

提交回复
热议问题