allow client to be created with no initial tokens
This commit is contained in:
		
							vanhempi
							
								
									3b1fc8e4ca
								
							
						
					
					
						commit
						61c7bd5ad6
					
				
							
								
								
									
										10
									
								
								wsclient.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								wsclient.js
									
									
									
									
									
								
							@ -7,9 +7,15 @@ var sni = require('sni');
 | 
				
			|||||||
var Packer = require('tunnel-packer');
 | 
					var Packer = require('tunnel-packer');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function run(copts) {
 | 
					function run(copts) {
 | 
				
			||||||
  var tokens = [ copts.token ];
 | 
					 | 
				
			||||||
  var activityTimeout = copts.activityTimeout || 2*60*1000;
 | 
					  var activityTimeout = copts.activityTimeout || 2*60*1000;
 | 
				
			||||||
  var pongTimeout = copts.pongTimeout || 10*1000;
 | 
					  var pongTimeout = copts.pongTimeout || 10*1000;
 | 
				
			||||||
 | 
					  // Allow the tunnel client to be created with no token. This will prevent the connection from
 | 
				
			||||||
 | 
					  // being established initialy and allows the caller to use `.append` for the first token so
 | 
				
			||||||
 | 
					  // they can get a promise that will provide feedback about invalid tokens.
 | 
				
			||||||
 | 
					  var tokens = [];
 | 
				
			||||||
 | 
					  if (copts.token) {
 | 
				
			||||||
 | 
					    tokens.push(copts.token);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  var wstunneler;
 | 
					  var wstunneler;
 | 
				
			||||||
  var authenticated = false;
 | 
					  var authenticated = false;
 | 
				
			||||||
@ -149,7 +155,7 @@ function run(copts) {
 | 
				
			|||||||
          connCallback();
 | 
					          connCallback();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // TODO: handle the versions and commands provided by 'hello' - isn't super important
 | 
					        // TODO: handle the versions and commands provided by 'hello' - isn't super important
 | 
				
			||||||
        // yet since there is only one version and set up commands.
 | 
					        // yet since there is only one version and set of commands.
 | 
				
			||||||
        err = null;
 | 
					        err = null;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      else {
 | 
					      else {
 | 
				
			||||||
 | 
				
			|||||||
		Ladataan…
	
	
			
			x
			
			
		
	
		Viittaa uudesa ongelmassa
	
	Block a user