Skip to content

Commit

Permalink
Merge pull request #5143 from fishface60/refactor-MapToolServer
Browse files Browse the repository at this point in the history
Retain serviceIdentifier in MapToolServer objects
  • Loading branch information
cwisniew authored Jan 19, 2025
2 parents a97b8e3 + d7d6ca4 commit ac34bdf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/net/rptools/maptool/server/MapToolServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Map.Entry;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.swing.SwingUtilities;
import net.rptools.clientserver.ConnectionFactory;
Expand Down Expand Up @@ -67,6 +68,7 @@ public enum State {
Stopped
}

@Nonnull private final String serviceIdentifier;
private final Server server;
private final MessageHandler messageHandler;
private final Router router;
Expand Down Expand Up @@ -97,6 +99,7 @@ public MapToolServer(
boolean useUPnP,
ServerPolicy policy,
ServerSidePlayerDatabase playerDb) {
this.serviceIdentifier = id;
this.config = config;
this.useUPnP = useUPnP;
this.policy = new ServerPolicy(policy);
Expand Down Expand Up @@ -204,6 +207,19 @@ public int getPort() {
return config == null ? -1 : config.getPort();
}

/**
* Get the ID that this server responds to service announcement requests with.
*
* @return The identifier or null if it's not being announced.
*/
@Nullable
public String getServiceIdentifier() {
if (announcer == null) {
return null;
}
return serviceIdentifier;
}

private void connectionAdded(Connection conn) {
var handshake =
new ServerHandshake(
Expand Down

0 comments on commit ac34bdf

Please sign in to comment.