+
+ /**
+ * add a IClient to the session
+ *
+ * add the client to the client list file
+ * @param client client to add to the session
+ */
+ protected void addClient(IClient client)
+ {
+ if (client == null)
+ this.slog.error("Try to add a null client to the session ");
+ else
+ this.clist.addClient(client.getClientHandle(), getClientWatcher().getChangedState());
+ }
+
+/**
+ *
+ * removes a client from the current session
+ * removes the client from the session client list
+ * if the client is the last one from the session (ClientList), the current session is removed
+ * from active session list.
+ *
+ * @param client client to remove
+ */
+ protected void removeClient(IClient client)
+ {
+ if (client == null)
+ {
+ this.slog.error("Try to remove a null client.");
+ return;
+ }
+ this.clist.removeClient(client.getClientHandle(), getClientWatcher().getChangedState());
+ if (this.clist.retrieveClientList() == null|| this.clist.retrieveClientList().length<1)
+ {//assume it is the last client has been removed shutting down session
+ System.out.println("last client removed: removing session");
+ this.getSessionManager().removeSession(client.getSessionHandle());
+
+ }
+ else
+ {
+ this.slog.debug("Still "+this.clist.retrieveClientList().length +" active clients");
+ System.out.println("Still "+(this.clist.retrieveClientList()==null?"null":this.clist.retrieveClientList().length+"") +" active clients");
+ }
+ }
+/**
+ * @return the sessionManager
+ */
+protected SimpleSessionManager getSessionManager() {
+ return sessionManager;
+}
+/**
+ * @param sessionManager the sessionManager to set
+ */
+protected void setSessionManager(SimpleSessionManager sessionManager) {
+ this.sessionManager = sessionManager;
+}