mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUAC-1100: Add getActiveConnections() function to Connectable.
This commit is contained in:
@@ -51,4 +51,13 @@ public interface Connectable {
|
||||
public GuacamoleSocket connect(GuacamoleClientInformation info)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns the number of active connections associated with this object.
|
||||
* Implementations may simply return 0 if this value is not tracked.
|
||||
*
|
||||
* @return
|
||||
* The number of active connections associated with this object.
|
||||
*/
|
||||
public int getActiveConnections();
|
||||
|
||||
}
|
||||
|
@@ -78,6 +78,11 @@ public class SimpleConnection extends AbstractConnection {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveConnections() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleSocket connect(GuacamoleClientInformation info)
|
||||
throws GuacamoleException {
|
||||
|
@@ -86,6 +86,11 @@ public class SimpleConnectionGroup extends AbstractConnectionGroup {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveConnections() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getConnectionIdentifiers() {
|
||||
return connectionIdentifiers;
|
||||
|
@@ -22,13 +22,10 @@
|
||||
|
||||
package org.glyptodon.guacamole.net.basic.rest.connection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
import org.glyptodon.guacamole.GuacamoleException;
|
||||
import org.glyptodon.guacamole.net.auth.Connection;
|
||||
import org.glyptodon.guacamole.net.auth.ConnectionRecord;
|
||||
import org.glyptodon.guacamole.net.basic.rest.connectiongroup.APIConnectionGroup;
|
||||
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
|
||||
|
||||
/**
|
||||
@@ -65,9 +62,9 @@ public class APIConnection {
|
||||
private Map<String, String> parameters;
|
||||
|
||||
/**
|
||||
* The count of currently active users for this connection.
|
||||
* The count of currently active connections using this connection.
|
||||
*/
|
||||
private int activeUsers;
|
||||
private int activeConnections;
|
||||
|
||||
/**
|
||||
* Create an empty APIConnection.
|
||||
@@ -85,23 +82,12 @@ public class APIConnection {
|
||||
public APIConnection(Connection connection)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Set identifying information
|
||||
// Set connection information
|
||||
this.name = connection.getName();
|
||||
this.identifier = connection.getIdentifier();
|
||||
|
||||
// Set proper parent identifier, using root identifier if needed
|
||||
this.parentIdentifier = connection.getParentIdentifier();
|
||||
if (this.parentIdentifier == null)
|
||||
this.parentIdentifier = APIConnectionGroup.ROOT_IDENTIFIER;
|
||||
this.activeConnections = connection.getActiveConnections();
|
||||
|
||||
// Set the number of currently active users
|
||||
this.activeUsers = 0;
|
||||
|
||||
for (ConnectionRecord history : connection.getHistory()) {
|
||||
if (history.isActive())
|
||||
this.activeUsers++;
|
||||
}
|
||||
|
||||
// Set protocol from configuration
|
||||
GuacamoleConfiguration configuration = connection.getConfiguration();
|
||||
this.protocol = configuration.getProtocol();
|
||||
@@ -190,19 +176,24 @@ public class APIConnection {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of currently active users for this connection.
|
||||
* @return The number of currently active users for this connection.
|
||||
* Returns the number of currently active connections using this
|
||||
* connection.
|
||||
*
|
||||
* @return
|
||||
* The number of currently active usages of this connection.
|
||||
*/
|
||||
public int getActiveUsers() {
|
||||
return activeUsers;
|
||||
public int getActiveConnections() {
|
||||
return activeConnections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of currently active users for this connection.
|
||||
* @param activeUsers The number of currently active users for this connection.
|
||||
* Set the number of currently active connections using this connection.
|
||||
*
|
||||
* @param activeConnections
|
||||
* The number of currently active usages of this connection.
|
||||
*/
|
||||
public void setActiveUsers(int activeUsers) {
|
||||
this.activeUsers = activeUsers;
|
||||
public void setActiveUsers(int activeConnections) {
|
||||
this.activeConnections = activeConnections;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -40,8 +40,18 @@ import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
|
||||
*/
|
||||
public class APIConnectionWrapper implements Connection {
|
||||
|
||||
/**
|
||||
* The wrapped APIConnection.
|
||||
*/
|
||||
private final APIConnection apiConnection;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new APIConnectionWrapper which wraps the given APIConnection
|
||||
* as a Connection.
|
||||
*
|
||||
* @param apiConnection
|
||||
* The APIConnection to wrap.
|
||||
*/
|
||||
public APIConnectionWrapper(APIConnection apiConnection) {
|
||||
this.apiConnection = apiConnection;
|
||||
}
|
||||
@@ -76,6 +86,11 @@ public class APIConnectionWrapper implements Connection {
|
||||
apiConnection.setParentIdentifier(parentIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveConnections() {
|
||||
return apiConnection.getActiveConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleConfiguration getConfiguration() {
|
||||
|
||||
|
@@ -61,6 +61,11 @@ public class APIConnectionGroup {
|
||||
*/
|
||||
private Type type;
|
||||
|
||||
/**
|
||||
* The count of currently active connections using this connection group.
|
||||
*/
|
||||
private int activeConnections;
|
||||
|
||||
/**
|
||||
* All child connection groups. If children are not being queried, this may
|
||||
* be omitted.
|
||||
@@ -91,6 +96,7 @@ public class APIConnectionGroup {
|
||||
|
||||
this.name = connectionGroup.getName();
|
||||
this.type = connectionGroup.getType();
|
||||
this.activeConnections = connectionGroup.getActiveConnections();
|
||||
|
||||
}
|
||||
|
||||
@@ -206,4 +212,26 @@ public class APIConnectionGroup {
|
||||
this.childConnections = childConnections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of currently active connections using this
|
||||
* connection group.
|
||||
*
|
||||
* @return
|
||||
* The number of currently active usages of this connection group.
|
||||
*/
|
||||
public int getActiveConnections() {
|
||||
return activeConnections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of currently active connections using this connection
|
||||
* group.
|
||||
*
|
||||
* @param activeConnections
|
||||
* The number of currently active usages of this connection group.
|
||||
*/
|
||||
public void setActiveUsers(int activeConnections) {
|
||||
this.activeConnections = activeConnections;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -25,9 +25,7 @@ package org.glyptodon.guacamole.net.basic.rest.connectiongroup;
|
||||
import java.util.Set;
|
||||
import org.glyptodon.guacamole.GuacamoleException;
|
||||
import org.glyptodon.guacamole.net.GuacamoleSocket;
|
||||
import org.glyptodon.guacamole.net.auth.Connection;
|
||||
import org.glyptodon.guacamole.net.auth.ConnectionGroup;
|
||||
import org.glyptodon.guacamole.net.auth.Directory;
|
||||
import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
|
||||
|
||||
/**
|
||||
@@ -92,6 +90,11 @@ public class APIConnectionGroupWrapper implements ConnectionGroup {
|
||||
return apiConnectionGroup.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveConnections() {
|
||||
return apiConnectionGroup.getActiveConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getConnectionIdentifiers() {
|
||||
throw new UnsupportedOperationException("Operation not supported.");
|
||||
|
@@ -102,12 +102,12 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
||||
this.isExpanded = template.isExpanded;
|
||||
|
||||
/**
|
||||
* The number of currently active users for this connection. This field
|
||||
* has no meaning for a connection group, and may be null or undefined.
|
||||
* The number of currently active users for this connection or
|
||||
* connection group, if known.
|
||||
*
|
||||
* @type Number
|
||||
*/
|
||||
this.activeUsers = template.activeUsers;
|
||||
this.activeConnections = template.activeConnections;
|
||||
|
||||
/**
|
||||
* The connection or connection group whose data is exposed within
|
||||
@@ -143,8 +143,8 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
||||
isConnection : true,
|
||||
isConnectionGroup : false,
|
||||
|
||||
// Count of currently active users
|
||||
activeUsers : connection.activeUsers,
|
||||
// Count of currently active connections using this connection
|
||||
activeConnections : connection.activeConnections,
|
||||
|
||||
// Wrapped item
|
||||
wrappedItem : connection
|
||||
@@ -198,6 +198,9 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
||||
// Already-converted children
|
||||
children : children,
|
||||
|
||||
// Count of currently active connection groups using this connection
|
||||
activeConnections : connectionGroup.activeConnections,
|
||||
|
||||
// Wrapped item
|
||||
wrappedItem : connectionGroup
|
||||
|
||||
|
@@ -21,7 +21,7 @@
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<div class="caption" ng-class="{active: item.activeUsers}">
|
||||
<div class="caption" ng-class="{active: item.activeConnections}">
|
||||
|
||||
<!-- Connection icon -->
|
||||
<div class="protocol">
|
||||
@@ -32,8 +32,8 @@
|
||||
<span class="name">{{item.name}}</span>
|
||||
|
||||
<!-- Active user count -->
|
||||
<span class="activeUserCount" ng-show="item.activeUsers">
|
||||
{{'HOME.INFO_ACTIVE_USER_COUNT' | translate:'{USERS: item.activeUsers}'}}
|
||||
<span class="activeUserCount" ng-show="item.activeConnections">
|
||||
{{'HOME.INFO_ACTIVE_USER_COUNT' | translate:'{USERS: item.activeConnections}'}}
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
@@ -21,7 +21,7 @@
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<div class="caption" ng-class="{active: item.activeUsers}">
|
||||
<div class="caption" ng-class="{active: item.activeConnections}">
|
||||
|
||||
<!-- Connection icon -->
|
||||
<div class="protocol">
|
||||
@@ -32,8 +32,8 @@
|
||||
<span class="name">{{item.name}}</span>
|
||||
|
||||
<!-- Active user count -->
|
||||
<span class="activeUserCount" ng-show="item.activeUsers">
|
||||
{{'MANAGE.INFO_ACTIVE_USER_COUNT' | translate:'{USERS: item.activeUsers}'}}
|
||||
<span class="activeUserCount" ng-show="item.activeConnections">
|
||||
{{'MANAGE.INFO_ACTIVE_USER_COUNT' | translate:'{USERS: item.activeConnections}'}}
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
@@ -81,13 +81,13 @@ angular.module('rest').factory('Connection', [function defineConnection() {
|
||||
this.parameters = template.parameters;
|
||||
|
||||
/**
|
||||
* The count of currently active users for this connection. This field
|
||||
* will be returned from the REST API during a get operation,
|
||||
* but may not be set when doing an update or create operation.
|
||||
* The count of currently active connections using this connection.
|
||||
* This field will be returned from the REST API during a get
|
||||
* operation, but manually setting this field will have no effect.
|
||||
*
|
||||
* @type Number
|
||||
*/
|
||||
this.activeUsers = template.activeUsers;
|
||||
this.activeConnections = template.activeConnections;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -91,6 +91,15 @@ angular.module('rest').factory('ConnectionGroup', [function defineConnectionGrou
|
||||
*/
|
||||
this.childConnectionGroups = template.childConnectionGroups;
|
||||
|
||||
/**
|
||||
* The count of currently active connections using this connection
|
||||
* group. This field will be returned from the REST API during a get
|
||||
* operation, but manually setting this field will have no effect.
|
||||
*
|
||||
* @type Number
|
||||
*/
|
||||
this.activeConnections = template.activeConnections;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user