mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +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