mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	show latency in remote/terminal every 10 secs (#5750)
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
		
							parent
							
								
									cd2ede8369
								
							
						
					
					
						commit
						cdab553800
					
				
					 2 changed files with 16 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			@ -293,6 +304,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;
 | 
			
		||||
        if (obj.socket != null) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue