Skip to content

Commit

Permalink
Leave all collaboration sessions on logout
Browse files Browse the repository at this point in the history
  • Loading branch information
ekuiter committed Nov 19, 2019
1 parent 0baab00 commit c489a2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.ovgu.spldev.varied.util.CollaboratorUtils;
import org.pmw.tinylog.Logger;

import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

Expand Down Expand Up @@ -40,6 +41,14 @@ public UUID register(WebSocket webSocket, UUID siteID) {
return collaborator.getSiteID();
}

public void unregister(UUID siteID) {
Objects.requireNonNull(siteID, "site ID not provided");
if (collaborators.containsKey(siteID)) {
collaborators.get(siteID).leaveAllCollaborativeSessions();
Logger.info("unregistered site {}", siteID);
}
}

public void broadcast(Message.IEncodable message) {
CollaboratorUtils.broadcast(collaborators.values(), message);
}
Expand Down
2 changes: 2 additions & 0 deletions server/src/main/java/de/ovgu/spldev/varied/WebSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public void onClose() {
// maintained if they do not properly leave a collaborative session. They should
// be removed and kernel-GC'ed after a timeout has passed, allowing some offline
// editing period, and while they are offline, shown as "inactive" in the UI.
// UPDATE: changed this for the meantime, does not allow offline editing at all
CollaboratorManager.getInstance().unregister(siteID);
}
}

Expand Down

0 comments on commit c489a2e

Please sign in to comment.