Skip to content

Commit

Permalink
v1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
matsfunk committed Sep 20, 2021
1 parent 95b07c1 commit 2c6944c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Binary file modified server/dist/OOCSI_server.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion server/src/nl/tue/id/oocsi/server/OOCSIServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 7 additions & 2 deletions server/src/nl/tue/id/oocsi/server/model/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 2c6944c

Please sign in to comment.