GUAC-997 Added active user count to REST API and UI.

This commit is contained in:
James Muehlner
2015-01-27 22:20:03 -08:00
parent 4573677880
commit f7e1f3a303
9 changed files with 86 additions and 2 deletions

View File

@@ -22,10 +22,12 @@
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;
@@ -62,6 +64,11 @@ public class APIConnection {
*/
private Map<String, String> parameters;
/**
* The count of currently active users for this connection.
*/
private int activeUsers;
/**
* Create an empty APIConnection.
*/
@@ -86,6 +93,14 @@ public class APIConnection {
this.parentIdentifier = connection.getParentIdentifier();
if (this.parentIdentifier == null)
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
GuacamoleConfiguration configuration = connection.getConfiguration();
@@ -173,5 +188,21 @@ public class APIConnection {
public void setProtocol(String protocol) {
this.protocol = protocol;
}
/**
* Returns the number of currently active users for this connection.
* @return The number of currently active users for this connection.
*/
public int getActiveUsers() {
return activeUsers;
}
/**
* Set the number of currently active users for this connection.
* @param activeUsers The number of currently active users for this connection.
*/
public void setActiveUsers(int activeUsers) {
this.activeUsers = activeUsers;
}
}