You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.8 KiB

<!doctype html>
<html>
<head>
<!-- Replace "localhost" with real IP address of controller, if default port changed, correct it too -->
<script type="text/javascript" src="http://localhost:8084/socket.io/socket.io.js"></script>
<script type="text/javascript" src="conn.js"></script>
</head>
<body>
<!--
Check the browser console!
-->
<script type="text/javascript">
servConn.namespace = 'mobile.0';
servConn._useStorage = false;
var states = [];
servConn.init({
name: 'mobile.0', // optional - default 'vis.0'
connLink: 'http://localhost:8084', // optional URL of the socket.io adapter
socketSession: '' // optional - used by authentication
}, {
onConnChange: function (isConnected) {
if (isConnected) {
console.log('connected');
servConn.getStates(function (err, _states) {
var count = 0;
for (var id in _states) {
count++;
}
console.log('Received ' + count + ' states.');
states = _states;
});
} else {
console.log('disconnected');
}
},
onRefresh: function () {
window.location.reload();
},
onUpdate: function (id, state) {
setTimeout(function () {
console.log('NEW VALUE of ' + id + ': ' + JSON.stringify(state));
states[id] = state;
}, 0);
},
onError: function (err) {
window.alert(_('Cannot execute %s for %s, because of insufficient permissions', err.command, err.arg), _('Insufficient permissions'), 'alert', 600);
}
});
</script>
</body>