mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-09 22:51:22 +00:00
GUAC-963: Remove managed client when view is destroyed if client is no longer connected.
This commit is contained in:
@@ -36,6 +36,36 @@ angular.module('client').factory('guacClientManager', ['ManagedClient',
|
||||
*/
|
||||
service.managedClients = {};
|
||||
|
||||
/**
|
||||
* Removes the existing ManagedClient associated with the connection having
|
||||
* the given ID, if any. If no such a ManagedClient already exists, this
|
||||
* function has no effect.
|
||||
*
|
||||
* @param {String} id
|
||||
* The ID of the connection whose ManagedClient should be removed.
|
||||
*
|
||||
* @returns {Boolean}
|
||||
* true if an existing client was removed, false otherwise.
|
||||
*/
|
||||
service.removeManagedClient = function replaceManagedClient(id) {
|
||||
|
||||
// Remove client if it exists
|
||||
if (id in service.managedClients) {
|
||||
|
||||
// Disconnect and remove
|
||||
service.managedClients[id].client.disconnect();
|
||||
delete service.managedClients[id];
|
||||
|
||||
// A client was removed
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// No client was removed
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new ManagedClient associated with the connection having the
|
||||
* given ID. If such a ManagedClient already exists, it is disconnected and
|
||||
@@ -56,8 +86,7 @@ angular.module('client').factory('guacClientManager', ['ManagedClient',
|
||||
service.replaceManagedClient = function replaceManagedClient(id, connectionParameters) {
|
||||
|
||||
// Disconnect any existing client
|
||||
if (id in service.managedClients)
|
||||
service.managedClients[id].client.disconnect();
|
||||
service.removeManagedClient(id);
|
||||
|
||||
// Set new client
|
||||
return service.managedClients[id] = ManagedClient.getInstance(id, connectionParameters);
|
||||
|
Reference in New Issue
Block a user