Get connection status on Socket.io client

后端 未结 5 1788
被撕碎了的回忆
被撕碎了的回忆 2020-12-23 10:50

I\'m using Socket.io, and I\'d like to know the status of connection to the server from the client-side.

Something like this:

socket.status // return         


        
5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 11:30

    You can check whether the connection was lost or not by using this function:-

    var socket = io( /**connection**/ );
    socket.on('disconnect', function(){
    //Your Code Here
    });
    

    Hope it will help you.

提交回复
热议问题