From 7713069496195efb1bf365d16ee4445c9eebf852 Mon Sep 17 00:00:00 2001 From: Lars Simon Winzer Date: Fri, 20 Mar 2026 16:22:47 +0100 Subject: [PATCH] Add: Make SessionManager use SessionHandle --- .../network/sessions/SessionManager.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/network/sessions/SessionManager.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/network/sessions/SessionManager.java index 6702543..17f06bb 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/network/sessions/SessionManager.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/network/sessions/SessionManager.java @@ -5,7 +5,7 @@ import java.util.concurrent.ConcurrentHashMap; /** Manages active sessions in the server. */ public class SessionManager { - private Map sessions; + private Map sessions; /** Constructs a new SessionManager. */ public SessionManager() { @@ -17,8 +17,8 @@ public class SessionManager { * * @param session the session to add */ - public void addSession(Session session) { - sessions.put(session.getId(), session); + public void addSession(SessionHandle handle) { + sessions.put(handle.session().getId(), handle); } /** @@ -28,7 +28,13 @@ public class SessionManager { * @return the removed session, or null if not found */ public Session removeSession(SessionId id) { - return sessions.remove(id); + SessionHandle handle = sessions.remove(id); + + if (handle == null) { + return null; + } + + return handle.session(); } /** @@ -38,7 +44,13 @@ public class SessionManager { * @return the removed session, or null if not found */ public Session removeSession(Session session) { - return sessions.remove(session.getId()); + SessionHandle handle = sessions.remove(session.getId()); + + if (handle == null) { + return null; + } + + return handle.session(); } /** @@ -48,6 +60,12 @@ public class SessionManager { * @return the session with the specified ID, or null if not found */ public Session getSessionById(SessionId id) { - return sessions.get(id); + SessionHandle handle = sessions.get(id); + + if (handle == null) { + return null; + } + + return handle.session(); } }