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