node.js - Get connection status on Socket.io client -
i'm using socket.io, , i'd know status of connection server client-side.
something this:
socket.status // return true if connected, false otherwise i need information give visual feedback user if connection has dropped or has disconnected reason.
you can check socket.connected property:
var socket = io.connect(); console.log('check 1', socket.connected); socket.on('connect', function() { console.log('check 2', socket.connected); }); it's updated dynamically, if connection lost it'll set false until client picks connection again. easy check setinterval or that.
another solution catch disconnect events , track status yourself.
Comments
Post a Comment