07.05.2018, 10:57
@Thomas, WebSocket is much better for performance and CPU load. If Opera works correctly on your devices, there's no point in using long polling.
@savas, try this solution (for now it will only work with admin account). Your device must be running latest firmware as well. If it works for you then I'll provide a full solution for non-admin users.
@savas, try this solution (for now it will only work with admin account). Your device must be running latest firmware as well. If it works for you then I'll provide a full solution for non-admin users.
Code:
if (!window.WebSocket) {
function doObjectUpdate(res) {
if (typeof res == 'object' && res.updatetime) {
if (res.updatetime != Globals.updateTime) {
Globals.updateTime = res.updatetime;
$.each(res.data || [], function(_, obj) {
objectStore.registerOne(obj.address, obj.datadec);
});
}
}
startObjectUpdate();
}
function startObjectUpdate() {
$.ajax({
url: '/scada-main/objects/update',
type: 'GET',
dataType: 'json',
data: { upd: Globals.updateTime },
error: doObjectUpdate,
success: doObjectUpdate,
timeout: 60 * 1000
});
}
function setObjectValueSend(data) {
$.ajax({
url: '/scada-main/objects/setvalue',
type: 'POST',
data: Scada.encodeData(data)
});
}
localbus.init = function() {};
}