mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 09:03:21 +00:00 
			
		
		
		
	GUAC-977: Automatically disconnect all connections when window/tab is closed.
This commit is contained in:
		| @@ -23,8 +23,14 @@ | ||||
| /** | ||||
|  * A service for managing several active Guacamole clients. | ||||
|  */ | ||||
| angular.module('client').factory('guacClientManager', ['ManagedClient', | ||||
|         function guacClientManager(ManagedClient) { | ||||
| angular.module('client').factory('guacClientManager', ['$injector', | ||||
|         function guacClientManager($injector) { | ||||
|  | ||||
|     // Required types | ||||
|     var ManagedClient = $injector.get('ManagedClient'); | ||||
|  | ||||
|     // Required services | ||||
|     var $window = $injector.get('$window'); | ||||
|  | ||||
|     var service = {}; | ||||
|  | ||||
| @@ -121,6 +127,15 @@ angular.module('client').factory('guacClientManager', ['ManagedClient', | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     // Disconnect all clients when window is unloaded | ||||
|     $window.addEventListener('unload', function disconnectAllClients() { | ||||
|  | ||||
|         // Disconnect each managed client | ||||
|         for (var id in service.managedClients) | ||||
|             service.managedClients[id].client.disconnect(); | ||||
|  | ||||
|     }); | ||||
|  | ||||
|     return service; | ||||
|  | ||||
| }]); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user