diff --git a/server/dist/OOCSI_server.jar b/server/dist/OOCSI_server.jar index a1c0230..ff5ef2a 100644 Binary files a/server/dist/OOCSI_server.jar and b/server/dist/OOCSI_server.jar differ diff --git a/server/src/nl/tue/id/oocsi/server/OOCSIServer.java b/server/src/nl/tue/id/oocsi/server/OOCSIServer.java index bc05ebf..80c0fd7 100644 --- a/server/src/nl/tue/id/oocsi/server/OOCSIServer.java +++ b/server/src/nl/tue/id/oocsi/server/OOCSIServer.java @@ -29,7 +29,7 @@ public class OOCSIServer extends Server { // constants - public static final String VERSION = "1.21"; + public static final String VERSION = "1.22"; // defaults for different services private int maxClients = 100; diff --git a/server/src/nl/tue/id/oocsi/server/model/Channel.java b/server/src/nl/tue/id/oocsi/server/model/Channel.java index f60bf83..4e36b36 100644 --- a/server/src/nl/tue/id/oocsi/server/model/Channel.java +++ b/server/src/nl/tue/id/oocsi/server/model/Channel.java @@ -110,9 +110,13 @@ public void send(Message message) { if (message.data.containsKey(RETAIN_MESSAGE)) { Object retainTimeoutRaw = message.data.getOrDefault(RETAIN_MESSAGE, "0"); try { + // retrieve timeout and restrict timeout to 2 days long timeout = Long.parseLong(retainTimeoutRaw.toString()); - message.validUntil = new Date(System.currentTimeMillis() + timeout); + timeout = Math.min(3600 * 24 * 2, timeout); + // set timeout and store retained message + message.validUntil = new Date(System.currentTimeMillis() + timeout * 1000); retainedMessage = message; + OOCSIServer.log("Retained message stored for channel '" + this.token + "' for " + timeout + "secs."); } catch (Exception e) { // do nothing } @@ -232,7 +236,8 @@ protected void closeEmptyChannels() { } // it is empty now, remove sub channel - if (!(subChannel instanceof Client) && subChannel.subChannels.size() == 0) { + if (!(subChannel instanceof Client) && subChannel.subChannels.size() == 0 + && (subChannel.retainedMessage == null || !subChannel.retainedMessage.isValid())) { subChannels.remove(subChannel.getName()); if (!subChannel.isPrivate()) { OOCSIServer.logConnection(getName(), subChannel.getName(), "closed empty channel", new Date());