1. Add latency timer and callback opportunity to CreateAgentRedirect
2. Add latency to Remote Desktop view
This commit is contained in:
parent
d0ad25795b
commit
9af543fe10
|
@ -1912,6 +1912,10 @@ function createMeshCore(agent) {
|
||||||
if (sdp != null) { ws.write({ type: 'answer', ctrlChannel: '102938', sdp: sdp }); }
|
if (sdp != null) { ws.write({ type: 'answer', ctrlChannel: '102938', sdp: sdp }); }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'latency': {
|
||||||
|
ws.write({ type: 'latency', ctrlChannel: '102938', time: obj.time });
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
|
||||||
obj.webrtc = null;
|
obj.webrtc = null;
|
||||||
obj.debugmode = 0;
|
obj.debugmode = 0;
|
||||||
obj.serverIsRecording = false;
|
obj.serverIsRecording = false;
|
||||||
|
obj.latency = { timer: null, lastSend: 0, current: 0, send: false, callbacks: [] };
|
||||||
if (domainUrl == null) { domainUrl = '/'; }
|
if (domainUrl == null) { domainUrl = '/'; }
|
||||||
|
|
||||||
// Console Message
|
// Console Message
|
||||||
|
@ -73,6 +74,9 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
|
||||||
if (controlMsg.type == 'console') {
|
if (controlMsg.type == 'console') {
|
||||||
obj.consoleMessage = controlMsg.msg;
|
obj.consoleMessage = controlMsg.msg;
|
||||||
if (obj.onConsoleMessageChange) { obj.onConsoleMessageChange(obj, obj.consoleMessage); }
|
if (obj.onConsoleMessageChange) { obj.onConsoleMessageChange(obj, obj.consoleMessage); }
|
||||||
|
} else if (controlMsg.type = 'latency') {
|
||||||
|
obj.latency.current = (new Date().getTime()) - controlMsg.time;
|
||||||
|
obj.latency.onUpdate();
|
||||||
} else if (obj.webrtc != null) {
|
} else if (obj.webrtc != null) {
|
||||||
if (controlMsg.type == 'answer') {
|
if (controlMsg.type == 'answer') {
|
||||||
obj.webrtc.setRemoteDescription(new RTCSessionDescription(controlMsg), function () { /*console.log('WebRTC remote ok');*/ }, obj.xxCloseWebRTC);
|
obj.webrtc.setRemoteDescription(new RTCSessionDescription(controlMsg), function () { /*console.log('WebRTC remote ok');*/ }, obj.xxCloseWebRTC);
|
||||||
|
@ -98,6 +102,17 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
obj.latencyTimer = function() {
|
||||||
|
obj.latency.send = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.latency.onUpdate = function(func) {
|
||||||
|
if (func != null) { obj.latency.callbacks.push(func); return; }
|
||||||
|
if (obj.latency.callbacks.length > 0) {
|
||||||
|
for (var x in obj.latency.callbacks) obj.latency.callbacks[x](obj.latency.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
obj.xxOnMessage = function (e) {
|
obj.xxOnMessage = function (e) {
|
||||||
//console.log('Recv', e.data, e.data.byteLength, obj.State);
|
//console.log('Recv', e.data, e.data.byteLength, obj.State);
|
||||||
if (obj.State < 3) {
|
if (obj.State < 3) {
|
||||||
|
@ -149,6 +164,11 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof e.data == 'object') {
|
if (typeof e.data == 'object') {
|
||||||
|
if (obj.latency.timer == null) {
|
||||||
|
obj.latency.timer = setInterval(obj.latencyTimer, 3000);
|
||||||
|
}
|
||||||
|
if (obj.latency.send) { obj.latency.send = false; obj.sendCtrlMsg('{"ctrlChannel":"102938","type":"latency","time":'+ new Date().getTime() +'}'); }
|
||||||
|
|
||||||
if (fileReaderInuse == true) { fileReaderAcc.push(e.data); return; }
|
if (fileReaderInuse == true) { fileReaderAcc.push(e.data); return; }
|
||||||
if (fileReader.readAsBinaryString && (obj.m.ProcessBinaryData == null)) {
|
if (fileReader.readAsBinaryString && (obj.m.ProcessBinaryData == null)) {
|
||||||
// Chrome & Firefox (Draft)
|
// Chrome & Firefox (Draft)
|
||||||
|
@ -248,7 +268,8 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
|
||||||
|
|
||||||
obj.Stop = function (x) {
|
obj.Stop = function (x) {
|
||||||
if (obj.debugmode == 1) { console.log('stop', x); }
|
if (obj.debugmode == 1) { console.log('stop', x); }
|
||||||
|
obj.latency.current = 0;
|
||||||
|
obj.latency.onUpdate();
|
||||||
// Clean up WebRTC
|
// Clean up WebRTC
|
||||||
obj.xxCloseWebRTC();
|
obj.xxCloseWebRTC();
|
||||||
|
|
||||||
|
|
|
@ -515,6 +515,7 @@
|
||||||
<span id=connectbutton1hspan> <input type=button id=connectbutton1h value="HW Connect" title="Connect using Intel AMT hardware KVM" onclick=connectDesktop(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
|
<span id=connectbutton1hspan> <input type=button id=connectbutton1h value="HW Connect" title="Connect using Intel AMT hardware KVM" onclick=connectDesktop(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
|
||||||
<span id=disconnectbutton1span> <input type=button id=disconnectbutton1 value="Disconnect" onclick=connectDesktop(event,0) onkeypress="return false" onkeydown="return false" /></span>
|
<span id=disconnectbutton1span> <input type=button id=disconnectbutton1 value="Disconnect" onclick=connectDesktop(event,0) onkeypress="return false" onkeydown="return false" /></span>
|
||||||
<span id="deskstatus">Disconnected</span>
|
<span id="deskstatus">Disconnected</span>
|
||||||
|
<span id="connectLatency">(Ping: <span id="connectLatencyTime">0</span>ms)</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id=deskarea2 style="">
|
<div id=deskarea2 style="">
|
||||||
|
@ -5860,6 +5861,7 @@
|
||||||
desktop.m.onDisplayinfo = deskDisplayInfo;
|
desktop.m.onDisplayinfo = deskDisplayInfo;
|
||||||
desktop.m.onScreenSizeChange = deskAdjust;
|
desktop.m.onScreenSizeChange = deskAdjust;
|
||||||
desktop.Start(desktopNode._id);
|
desktop.Start(desktopNode._id);
|
||||||
|
desktop.latency.onUpdate(function(ms) { QH('connectLatencyTime', ms); });
|
||||||
desktop.contype = 1;
|
desktop.contype = 1;
|
||||||
} else if (contype == 3) {
|
} else if (contype == 3) {
|
||||||
// Ask for user sessions
|
// Ask for user sessions
|
||||||
|
|
Loading…
Reference in New Issue