Skip to content

Commit

Permalink
Allow idle timer to be disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartcaunt committed Dec 4, 2024
1 parent e5d205f commit 83843ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.ill.visa.vdi.domain.models;

import eu.ill.visa.core.entity.enumerations.InstanceMemberRole;
import eu.ill.visa.vdi.business.services.DesktopService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -10,7 +11,7 @@ public record DesktopSessionMember(String clientId, ConnectedUser connectedUser,
private static final Logger logger = LoggerFactory.getLogger(DesktopSessionMember.class);

public DesktopSessionMember(String clientId, ConnectedUser connectedUser, RemoteDesktopConnection remoteDesktopConnection, DesktopSession session) {
this(clientId, connectedUser, remoteDesktopConnection, session, new IdleSessionHandler());
this(clientId, connectedUser, remoteDesktopConnection, session, new IdleSessionHandler(remoteDesktopConnection.getClient().protocol().equals(DesktopService.GUACAMOLE_PROTOCOL)));
}

public void disconnect() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,29 @@ public class IdleSessionHandler {

private static final int IDLE_TIMEOUT_SECONDS = 30;

private final boolean enabled;
private Runnable onIdleCallback;
private Cancellable timer;

public IdleSessionHandler(boolean enabled) {
this.enabled = enabled;
}

public void start(Runnable onIdleCallback) {
if (this.timer != null) {
this.timer.cancel();
if (enabled) {
if (this.timer != null) {
this.timer.cancel();
}
this.onIdleCallback = onIdleCallback;
this.createTimer();
}
this.onIdleCallback = onIdleCallback;
this.createTimer();
}

public void reset() {
if (this.timer != null) {
this.timer.cancel();
this.createTimer();
}
this.createTimer();
}

public void stop() {
Expand Down

0 comments on commit 83843ef

Please sign in to comment.