How can a SignalR JavaScript client detect when a connection with the server is lost?
See Question&Answers more detail:osHow can a SignalR JavaScript client detect when a connection with the server is lost?
See Question&Answers more detail:osA hub has a method disconnect
which will allow you to add a callback when disconnection takes place:
myHub.disconnect(function() {
alert('Server has disconnected');
});
If you aren't using hubs then the code for the disconnect method will help you out:
$(connection).bind("onDisconnect", function (e, data) {
callback.call(connection);
});
This shows the syntax for hooking onto the onDisconnect event of the underlying connection.