You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nowjs
Hi,
I would like to give a feedback (changing icon) when the connection to
the server gets lost. Is there a way to detect this?
Thanks.
Stefan
Steve Wang
unread,
Oct 29, 2011, 7:45:48 PM10/29/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nowjs
Try
now.core.socketio.on('disconnect', function () {
alert('Disconnected from server.');
});
and
now.core.socketio.on('connect', function () {
alert('Connected to server.');
});
That should do the trick.
stefa_n
unread,
Oct 30, 2011, 9:03:34 AM10/30/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nowjs
Yes, this does the trick.Thanks Steve.
For others reading this:You'll have to wait till NowJS has loaded
SocketIO, so put this in/after the ready-event.Take care that it's
executed only once as a reconnect will call ready again.
When connection really get's lost SocketIO throws an error:Firebug
soiws sth like (translated from german):The connection to ... was
disrupted while the page was loadingsocket.io.js, 2293, this.websocket
= new Socket(this.prepareUrl() + query);
A network-connection can fail anytime for all kind of reasons. I
wouldn'tsee this as a real programming-error. Is there a way to turn
this off orcatch it without delving into SocketIO?