2012-04-18 05:05:32 +00:00
|
|
|
var socket, port;
|
|
|
|
|
|
2012-04-21 04:56:40 +00:00
|
|
|
$( function () {
|
2012-04-18 05:05:32 +00:00
|
|
|
port = window.location.port
|
|
|
|
|
socket = io.connect( "http://" + document.domain + ':' + port + '/' );
|
2012-04-21 04:56:40 +00:00
|
|
|
socket.on( 'connect', function () {
|
2012-04-18 05:05:32 +00:00
|
|
|
socket.on( 'refresh', function () {
|
|
|
|
|
window.location.reload();
|
|
|
|
|
} );
|
2012-04-21 04:56:40 +00:00
|
|
|
socket.on( 'reconnecting', function () {
|
2012-04-18 05:05:32 +00:00
|
|
|
console.log( 'Lost connection to anvil, attempting to reconnect', 'warning' );
|
|
|
|
|
} );
|
2012-04-21 04:56:40 +00:00
|
|
|
socket.on( 'reconnect', function () {
|
2012-04-18 05:05:32 +00:00
|
|
|
alert( 'Reconnection to anvil succeeded' );
|
|
|
|
|
} );
|
2012-04-21 04:56:40 +00:00
|
|
|
socket.on( 'reconnect_failed', function () {
|
2012-04-18 05:05:32 +00:00
|
|
|
console.log( 'Reconnected to anvil failed', 'error' );
|
|
|
|
|
} );
|
2012-04-21 04:56:40 +00:00
|
|
|
socket.on( 'connect_failed', function () {
|
2012-04-18 05:05:32 +00:00
|
|
|
console.log( 'Could not connect to anvil', 'error' );
|
|
|
|
|
} );
|
2012-04-21 04:56:40 +00:00
|
|
|
socket.on( 'disconnect', function () {
|
2012-04-18 05:05:32 +00:00
|
|
|
alert( 'Anvil server has disconnected', 'error' );
|
|
|
|
|
} );
|
|
|
|
|
} );
|
|
|
|
|
} );
|