diff options
3 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java b/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java index 5d551d9..8798813 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java @@ -66,6 +66,7 @@ public class AvailableClient implements Cloneable { if (this.inUseBy != null) { LOGGER.info("Client " + this + " is available again"); this.inUseBy = null; + if (this.connection != null) this.connection.invalidate(); } } this.lastConnectionCheck = 0; diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java index 91d5849..813b6f2 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java @@ -50,6 +50,7 @@ public class BwlpUserContext extends AbstractUserContext { private void addConn() throws GuacamoleCredentialsException { WrappedConnection connection = ConnectionManager.getForUser(authUser.getCredentials().getUsername(), groupid); if (connection != null) { + connection.setContext(this); connectionDirectory = new SimpleDirectory<Connection>(connection); } else { connectionDirectory = new SimpleDirectory<Connection>(); @@ -86,6 +87,10 @@ public class BwlpUserContext extends AbstractUserContext { return connectionDirectory; } + public void clearConnections() { + connectionDirectory = new SimpleDirectory<Connection>(); + } + public boolean hasValidConnection() { boolean ok = false; try { diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/WrappedConnection.java b/src/main/java/de/bwlehrpool/bwlp_guac/WrappedConnection.java index a2ecb52..95a014b 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/WrappedConnection.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/WrappedConnection.java @@ -11,6 +11,8 @@ public class WrappedConnection extends SimpleConnection { private boolean valid = true; + private BwlpUserContext context; + public WrappedConnection(String name, AvailableClient ac) { super(name, name, makeConfig(ac)); this.ac = ac.clone(); @@ -31,6 +33,14 @@ public class WrappedConnection extends SimpleConnection { public void invalidate() { this.valid = false; + if (this.context != null) { + this.context.clearConnections(); + this.context = null; + } + } + + public void setContext(BwlpUserContext context) { + this.context = context; } } |