mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	Added ?trace=2 support, to stringify trace output.
This commit is contained in:
		
							parent
							
								
									fba2ac227a
								
							
						
					
					
						commit
						b24a30ace6
					
				
					 2 changed files with 8 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -10,7 +10,7 @@ var MeshServerCreateControl = function (domain, authCookie) {
 | 
			
		|||
    obj.connectstate = 0;
 | 
			
		||||
    obj.pingTimer = null;
 | 
			
		||||
    obj.authCookie = authCookie;
 | 
			
		||||
    obj.trace = false;
 | 
			
		||||
    //obj.trace = false;
 | 
			
		||||
    
 | 
			
		||||
    obj.xxStateChange = function (newstate, errCode) {
 | 
			
		||||
        if (obj.State == newstate) return;
 | 
			
		||||
| 
						 | 
				
			
			@ -48,13 +48,17 @@ var MeshServerCreateControl = function (domain, authCookie) {
 | 
			
		|||
        if ((typeof message != 'object') || (message.action == 'pong')) { return; }
 | 
			
		||||
        if (message.action == 'ping') { obj.send({ action: 'pong' }); }
 | 
			
		||||
        if (message.action == 'close') { if (message.msg) { console.log(message.msg); } obj.Stop(message.cause); return; }
 | 
			
		||||
        if (obj.trace) { console.log('RECV', message); }
 | 
			
		||||
        if (obj.trace == 1) { console.log('RECV', message); }
 | 
			
		||||
        else if (obj.trace == 2) { console.log('RECV', JSON.stringify(message)); }
 | 
			
		||||
        if (obj.onMessage) obj.onMessage(obj, message);
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
    obj.send = function (x) {
 | 
			
		||||
        if (obj.socket != null && obj.connectstate == 1) {
 | 
			
		||||
            if (obj.trace && (x.action != 'ping')) { console.log('SEND', x); }
 | 
			
		||||
            if (x.action != 'ping') {
 | 
			
		||||
                if (obj.trace == 1) { console.log('SEND', x); }
 | 
			
		||||
                else if (obj.trace == 2) { console.log('SEND', JSON.stringify(x)); }
 | 
			
		||||
            }
 | 
			
		||||
            obj.socket.send(JSON.stringify(x));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue