| 
				
			 | 
			
			
				
				@@ -294,15 +294,29 @@ XMPP.prototype.getSessions = function () { 
			 | 
		
		
	
		
			
			| 
				294
			 | 
			
				294
			 | 
			
			
				
				 }; 
			 | 
		
		
	
		
			
			| 
				295
			 | 
			
				295
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				296
			 | 
			
				296
			 | 
			
			
				
				 XMPP.prototype.disconnect = function () { 
			 | 
		
		
	
		
			
			| 
				297
			 | 
			
				
			 | 
			
			
				
				-    if (this.disconnectInProgress || !this.connection || !this.connection.connected) 
			 | 
		
		
	
		
			
			| 
				298
			 | 
			
				
			 | 
			
			
				
				-    { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				297
			 | 
			
			
				
				+    if (this.disconnectInProgress 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				298
			 | 
			
			
				
				+            || !this.connection 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				299
			 | 
			
			
				
				+            || !this.connection.connected) { 
			 | 
		
		
	
		
			
			| 
				299
			 | 
			
				300
			 | 
			
			
				
				         this.eventEmitter.emit(JitsiConnectionEvents.WRONG_STATE); 
			 | 
		
		
	
		
			
			| 
				300
			 | 
			
				301
			 | 
			
			
				
				         return; 
			 | 
		
		
	
		
			
			| 
				301
			 | 
			
				302
			 | 
			
			
				
				     } 
			 | 
		
		
	
		
			
			| 
				302
			 | 
			
				303
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				303
			 | 
			
				304
			 | 
			
			
				
				     this.disconnectInProgress = true; 
			 | 
		
		
	
		
			
			| 
				304
			 | 
			
				305
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				306
			 | 
			
			
				
				+    // XXX Strophe is asynchronously sending by default. Unfortunately, that 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				307
			 | 
			
			
				
				+    // means that there may not be enough time to send an unavailable presence 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				308
			 | 
			
			
				
				+    // or disconnect at all. Switching Strophe to synchronous sending is not 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				309
			 | 
			
			
				
				+    // much of an option because it may lead to a noticeable delay in navigating 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				310
			 | 
			
			
				
				+    // away from the current location. As a compromise, we will try to increase 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				311
			 | 
			
			
				
				+    // the chances of sending an unavailable presence and/or disconecting within 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				312
			 | 
			
			
				
				+    // the short time span that we have upon unloading by invoking flush() on 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				313
			 | 
			
			
				
				+    // the connection. We flush() once before disconnect() in order to attemtp 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				314
			 | 
			
			
				
				+    // to have its unavailable presence at the top of the send queue. We flush() 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				315
			 | 
			
			
				
				+    // once more after disconnect() in order to attempt to have its unavailable 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				316
			 | 
			
			
				
				+    // presence sent as soon as possible. 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				317
			 | 
			
			
				
				+    this.connection.flush(); 
			 | 
		
		
	
		
			
			| 
				305
			 | 
			
				318
			 | 
			
			
				
				     this.connection.disconnect(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				319
			 | 
			
			
				
				+    this.connection.flush(); 
			 | 
		
		
	
		
			
			| 
				306
			 | 
			
				320
			 | 
			
			
				
				 }; 
			 | 
		
		
	
		
			
			| 
				307
			 | 
			
				321
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				308
			 | 
			
				322
			 | 
			
			
				
				 module.exports = XMPP; 
			 |