show latency in remote/terminal every 10 secs (#5750)

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
Simon Smith 2024-01-31 14:06:31 +00:00 committed by GitHub
parent cd2ede8369
commit cdab553800
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View File

@ -81,6 +81,17 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
obj.xxOnSocketConnected = function () {
if (obj.debugmode == 1) { console.log('onSocketConnected'); }
//obj.debug('Agent Redir Socket Connected');
if (!obj.latency.lastSend){
obj.latency.lastSend = setInterval(function(){
if (obj.latency.current == -1) {
clearInterval(obj.latency.lastSend);
obj.latency.lastSend = null;
} else {
obj.sendCtrlMsg(JSON.stringify({ctrlChannel:102938,type:"rtt",time:(new Date().getTime())}));
}
}, 10000);
}
obj.sendCtrlMsg(JSON.stringify({ctrlChannel:102938,type:"rtt",time:(new Date().getTime())}));
obj.xxStateChange(2);
}
@ -97,7 +108,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
if (obj.onMetadataChange) obj.onMetadataChange(obj.metadata);
} else if ((controlMsg.type == 'rtt') && (typeof controlMsg.time == 'number')) {
obj.latency.current = (new Date().getTime()) - controlMsg.time;
if (obj.latency.callbacks != null) { obj.latency.callback(obj.latency.current); }
if (obj.latency.callback != null) { obj.latency.callback(obj.latency.current); }
} else if (obj.webrtc != null) {
if (controlMsg.type == 'answer') {
obj.webrtc.setRemoteDescription(new RTCSessionDescription(controlMsg), function () { /*console.log('WebRTC remote ok');*/ }, obj.xxCloseWebRTC);
@ -292,6 +303,9 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
// Clean up WebRTC
obj.xxCloseWebRTC();
// clear RTT timer
obj.latency.current = -1;
//obj.debug('Agent Redir Socket Stopped');
obj.connectstate = -1;

View File

@ -9187,7 +9187,7 @@
//desktop.m.onDisplayinfo = deskDisplayInfo;
desktop.m.onScreenSizeChange = deskAdjust;
desktop.Start(desktopNode._id);
desktop.latency.callback = function(ms) { console.log('latency', ms); updateSessionTime(); };
desktop.latency.callback = function(ms) { /* console.log('latency', ms); */ updateSessionTime(); };
desktop.contype = 1;
} else if (contype == 3) {
// Ask for user sessions