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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -