From ecb12c61989e4f4452c8296d073096d9e9603cc5 Mon Sep 17 00:00:00 2001 From: Thomas Kunze Date: Sat, 29 Oct 2022 20:55:20 +0200 Subject: [PATCH 1/6] add stun and turn servers of openrelayproject --- .../simple/client/WebRTCClientConnection.java | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/rptools/clientserver/simple/client/WebRTCClientConnection.java b/src/main/java/net/rptools/clientserver/simple/client/WebRTCClientConnection.java index 2b6aadf037..02428eb00c 100644 --- a/src/main/java/net/rptools/clientserver/simple/client/WebRTCClientConnection.java +++ b/src/main/java/net/rptools/clientserver/simple/client/WebRTCClientConnection.java @@ -162,15 +162,37 @@ public void onError(Exception ex) { } private void init() { - RTCIceServer iceServer = new RTCIceServer(); - iceServer.urls.add("stun:stun.l.google.com:19302"); - iceServer.urls.add("stun:stun1.l.google.com:19302"); - iceServer.urls.add("stun:stun2.l.google.com:19302"); - iceServer.urls.add("stun:stun3.l.google.com:19302"); - iceServer.urls.add("stun:stun4.l.google.com:19302"); - rtcConfig = new RTCConfiguration(); - rtcConfig.iceServers.add(iceServer); + + var googleStun = new RTCIceServer(); + googleStun.urls.add("stun:stun.l.google.com:19302"); + googleStun.urls.add("stun:stun1.l.google.com:19302"); + googleStun.urls.add("stun:stun2.l.google.com:19302"); + googleStun.urls.add("stun:stun3.l.google.com:19302"); + googleStun.urls.add("stun:stun4.l.google.com:19302"); + rtcConfig.iceServers.add(googleStun); + + var openRelayStun = new RTCIceServer(); + openRelayStun.urls.add("stun:openrelay.metered.ca:80"); + rtcConfig.iceServers.add(openRelayStun); + + var openRelayTurn = new RTCIceServer(); + openRelayTurn.urls.add("turn:openrelay.metered.ca:80"); + openRelayTurn.username = "openrelayproject"; + openRelayTurn.password = "openrelayproject"; + rtcConfig.iceServers.add(openRelayTurn); + + var openRelayTurn2 = new RTCIceServer(); + openRelayTurn2.urls.add("turn:openrelay.metered.ca:443"); + openRelayTurn2.username = "openrelayproject"; + openRelayTurn2.password = "openrelayproject"; + rtcConfig.iceServers.add(openRelayTurn2); + + var openRelayTurn3 = new RTCIceServer(); + openRelayTurn3.urls.add("turn:openrelay.metered.ca:443?transport=tcp"); + openRelayTurn3.username = "openrelayproject"; + openRelayTurn3.password = "openrelayproject"; + rtcConfig.iceServers.add(openRelayTurn3); } @Override From 64b62c9635f16df6b08f87c08c7977e1b43f3b3f Mon Sep 17 00:00:00 2001 From: Thomas Kunze Date: Sat, 29 Oct 2022 21:30:11 +0200 Subject: [PATCH 2/6] move useWebRtc from AppState to ServerConfig, push and pull it from server registry. --- .../clientserver/ConnectionFactory.java | 5 +- .../rptools/maptool/client/AppActions.java | 3 +- .../net/rptools/maptool/client/AppState.java | 9 -- .../net/rptools/maptool/client/MapTool.java | 2 +- .../maptool/client/MapToolRegistry.java | 5 +- .../client/ui/ConnectToServerDialog.java | 59 ++------ .../maptool/client/ui/StartServerDialog.java | 5 +- .../ui/StartServerDialogPreferences.java | 10 ++ .../rptools/maptool/server/ServerConfig.java | 12 +- .../rptools/maptool/server/ServerPolicy.java | 4 +- .../client/ui/forms/connectToServerDialog.xml | 143 ++++++------------ 11 files changed, 86 insertions(+), 171 deletions(-) diff --git a/src/main/java/net/rptools/clientserver/ConnectionFactory.java b/src/main/java/net/rptools/clientserver/ConnectionFactory.java index c6f2ddf501..be79ed716b 100644 --- a/src/main/java/net/rptools/clientserver/ConnectionFactory.java +++ b/src/main/java/net/rptools/clientserver/ConnectionFactory.java @@ -22,7 +22,6 @@ import net.rptools.clientserver.simple.server.ServerConnection; import net.rptools.clientserver.simple.server.SocketServerConnection; import net.rptools.clientserver.simple.server.WebRTCServerConnection; -import net.rptools.maptool.client.AppState; import net.rptools.maptool.server.ServerConfig; public class ConnectionFactory { @@ -34,7 +33,7 @@ public static ConnectionFactory getInstance() { public ClientConnection createClientConnection(String id, ServerConfig config) throws IOException { - if (!AppState.useWebRTC() || config.isPersonalServer()) + if (!config.getUseWebRTC() || config.isPersonalServer()) return new SocketClientConnection(id, config.getHostName(), config.getPort()); return new WebRTCClientConnection(id, config); @@ -42,7 +41,7 @@ public ClientConnection createClientConnection(String id, ServerConfig config) public ServerConnection createServerConnection(ServerConfig config, HandshakeProvider handshake) throws IOException { - if (!AppState.useWebRTC() || config.isPersonalServer()) + if (!config.getUseWebRTC() || config.isPersonalServer()) return new SocketServerConnection(config.getPort(), handshake); return new WebRTCServerConnection(config, handshake); diff --git a/src/main/java/net/rptools/maptool/client/AppActions.java b/src/main/java/net/rptools/maptool/client/AppActions.java index 1db20f4e6f..c3c91ff45d 100644 --- a/src/main/java/net/rptools/maptool/client/AppActions.java +++ b/src/main/java/net/rptools/maptool/client/AppActions.java @@ -2253,7 +2253,8 @@ protected void executeAction() { serverProps.getPort(), serverProps.getRPToolsName(), "localhost", - serverProps.getUseEasyConnect()); + serverProps.getUseEasyConnect(), + serverProps.getUseWebRtc()); // Use the existing campaign Campaign campaign = MapTool.getCampaign(); diff --git a/src/main/java/net/rptools/maptool/client/AppState.java b/src/main/java/net/rptools/maptool/client/AppState.java index ae145be105..fe1aa578b0 100644 --- a/src/main/java/net/rptools/maptool/client/AppState.java +++ b/src/main/java/net/rptools/maptool/client/AppState.java @@ -43,7 +43,6 @@ public class AppState { private static boolean collectProfilingData = false; private static boolean isLoggingToConsole = false; private static boolean isLockedForBackgroundTask = false; - private static boolean useWebRTC = false; private static boolean enableFullScreenUI = true; private static PropertyChangeSupport changeSupport = new PropertyChangeSupport(AppState.class); @@ -218,14 +217,6 @@ public static void setNotificationEnforced(boolean enforce) { enforceNotification = enforce; } - public static boolean useWebRTC() { - return useWebRTC; - } - - public static void setUseWebRTC(boolean use) { - useWebRTC = use; - } - public static boolean isFullScreenUIEnabled() { return enableFullScreenUI; } diff --git a/src/main/java/net/rptools/maptool/client/MapTool.java b/src/main/java/net/rptools/maptool/client/MapTool.java index 573065291a..31c73cb92e 100644 --- a/src/main/java/net/rptools/maptool/client/MapTool.java +++ b/src/main/java/net/rptools/maptool/client/MapTool.java @@ -1060,7 +1060,7 @@ public static void startServer( try { MapToolRegistry.RegisterResponse result = MapToolRegistry.getInstance() - .registerInstance(config.getServerName(), config.getPort()); + .registerInstance(config.getServerName(), config.getPort(), config.getUseWebRTC()); if (result == MapToolRegistry.RegisterResponse.NAME_EXISTS) { MapTool.showError("msg.error.alreadyRegistered"); } diff --git a/src/main/java/net/rptools/maptool/client/MapToolRegistry.java b/src/main/java/net/rptools/maptool/client/MapToolRegistry.java index e7ba6b0a19..fec8746876 100644 --- a/src/main/java/net/rptools/maptool/client/MapToolRegistry.java +++ b/src/main/java/net/rptools/maptool/client/MapToolRegistry.java @@ -70,6 +70,7 @@ public static MapToolRegistry getInstance() { public static class SeverConnectionDetails { public String address; public int port; + public boolean webrtc; } public enum RegisterResponse { @@ -93,6 +94,7 @@ public SeverConnectionDetails findInstance(String id) { details.address = json.getAsJsonPrimitive("address").getAsString(); details.port = json.getAsJsonPrimitive("port").getAsInt(); + details.webrtc = json.getAsJsonPrimitive("webrtc").getAsBoolean(); return details; @@ -121,11 +123,12 @@ public List findAllInstances() { } } - public RegisterResponse registerInstance(String id, int port) { + public RegisterResponse registerInstance(String id, int port, boolean webrtc) { JsonObject body = new JsonObject(); body.addProperty("name", id); body.addProperty("port", port); body.addProperty("address", getAddress()); + body.addProperty("webrtc", webrtc); if (MapTool.isDevelopment()) { body.addProperty("version", "Dev"); } else { diff --git a/src/main/java/net/rptools/maptool/client/ui/ConnectToServerDialog.java b/src/main/java/net/rptools/maptool/client/ui/ConnectToServerDialog.java index 0cccc4d4e1..2737e9fd5e 100644 --- a/src/main/java/net/rptools/maptool/client/ui/ConnectToServerDialog.java +++ b/src/main/java/net/rptools/maptool/client/ui/ConnectToServerDialog.java @@ -33,14 +33,11 @@ import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; import javax.swing.table.AbstractTableModel; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableColumn; import net.rptools.lib.swing.SwingUtil; import net.rptools.maptool.client.AppConstants; -import net.rptools.maptool.client.AppState; import net.rptools.maptool.client.MapTool; import net.rptools.maptool.client.MapToolRegistry; import net.rptools.maptool.client.MapToolRegistry.SeverConnectionDetails; @@ -62,8 +59,7 @@ public class ConnectToServerDialog extends AbeillePanel 0); - } - - @Override - public void insertUpdate(DocumentEvent e) { - checkName(); - } - @Override - public void removeUpdate(DocumentEvent e) { - checkName(); - } - - @Override - public void changedUpdate(DocumentEvent e) { - checkName(); - } - }); - getUseWebRTCCheckBox().setEnabled(getServerNameTextField().getText().length() > 0); dialog.showDialog(); } @@ -264,10 +237,6 @@ public void initRefreshButton() { getRefreshButton().addActionListener(e -> updateRemoteServerList()); } - public JCheckBox getUseWebRTCCheckBox() { - return (JCheckBox) getComponent("@useWebRTC"); - } - public JTextField getUsernameTextField() { return (JTextField) getComponent("@username"); } @@ -327,8 +296,8 @@ private void handleOK() { } // OK ServerInfo info = (ServerInfo) getLocalServerList().getSelectedValue(); - port = info.port; - hostname = info.address.getHostAddress(); + connectionDetails.port = info.port; + connectionDetails.address = info.address.getHostAddress(); } if (SwingUtil.hasComponent(selectedPanel, "directPanel")) { // TODO: put these into a validation method @@ -352,8 +321,8 @@ private void handleOK() { getHostTextField().setText(host); // OK - port = portTemp; - hostname = host; + connectionDetails.port = portTemp; + connectionDetails.address = host; } if (SwingUtil.hasComponent(selectedPanel, "rptoolsPanel")) { String serverName = getServerNameTextField().getText().trim(); @@ -369,18 +338,12 @@ private void handleOK() { MapTool.showError(I18N.getText("ServerDialog.error.serverNotFound", serverName)); return; } - hostname = serverInfo.address; - try { - port = serverInfo.port; - } catch (NumberFormatException nfe) { - MapTool.showError("ServerDialog.error.portNumberException"); - return; - } + connectionDetails = serverInfo; } try { - InetAddress server = InetAddress.getByName(hostname); + InetAddress server = InetAddress.getByName(connectionDetails.address); InetAddress extAddress = InetAddress.getByName(externalAddress); - if (extAddress != null && extAddress.equals(server) && !getUseWebRTCCheckBox().isSelected()) { + if (extAddress != null && extAddress.equals(server) && !connectionDetails.webrtc) { boolean yes = MapTool.confirm( "ConnectToServerDialog.warning.doNotUseExternalAddress", @@ -393,8 +356,6 @@ private void handleOK() { } if (commit()) { accepted = true; - JCheckBox useWebRTCCheckBox = getUseWebRTCCheckBox(); - AppState.setUseWebRTC(useWebRTCCheckBox.isEnabled() && useWebRTCCheckBox.isSelected()); dialog.closeDialog(); } } diff --git a/src/main/java/net/rptools/maptool/client/ui/StartServerDialog.java b/src/main/java/net/rptools/maptool/client/ui/StartServerDialog.java index e9e7e7e84d..7dbbb40f4e 100644 --- a/src/main/java/net/rptools/maptool/client/ui/StartServerDialog.java +++ b/src/main/java/net/rptools/maptool/client/ui/StartServerDialog.java @@ -23,7 +23,6 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import net.rptools.maptool.client.AppPreferences; -import net.rptools.maptool.client.AppState; import net.rptools.maptool.client.MapTool; import net.rptools.maptool.client.swing.AbeillePanel; import net.rptools.maptool.client.swing.GenericDialog; @@ -264,9 +263,11 @@ public void initOKButton() { prefs.setLockTokenEditOnStart(lockTokenEditOnStartup.isSelected()); prefs.setLockPlayerMovementOnStart(lockPlayerMoveOnStartup.isSelected()); prefs.setPlayerLibraryLock(lockPlayerLibrary.isSelected()); + JCheckBox useWebRTCCheckBox = getUseWebRTCCheckBox(); - AppState.setUseWebRTC( + prefs.setKeyUseWebrtc( useWebRTCCheckBox.isEnabled() && useWebRTCCheckBox.isSelected()); + accepted = true; dialog.closeDialog(); } diff --git a/src/main/java/net/rptools/maptool/client/ui/StartServerDialogPreferences.java b/src/main/java/net/rptools/maptool/client/ui/StartServerDialogPreferences.java index 4032a2f847..87a90c821f 100644 --- a/src/main/java/net/rptools/maptool/client/ui/StartServerDialogPreferences.java +++ b/src/main/java/net/rptools/maptool/client/ui/StartServerDialogPreferences.java @@ -52,6 +52,8 @@ public class StartServerDialogPreferences { private static final String KEY_START_LOCKED_PLAYER_MOVEMENT = "lockPlayerMovementOnStartup"; private static final String KEY_LOCK_PLAYER_LIBRARY = "lockPlayerLibrary"; + private static final String KEY_USE_WEBRTC = "useWebRTC"; + private static Boolean useToolTipsForUnformattedRolls = null; public Player.Role getRole() { @@ -259,4 +261,12 @@ public boolean getPlayerLibraryLock() { public void setPlayerLibraryLock(boolean flag) { prefs.putBoolean(KEY_LOCK_PLAYER_LIBRARY, flag); } + + public boolean getUseWebRtc() { + return prefs.getBoolean(KEY_USE_WEBRTC, false); + } + + public void setKeyUseWebrtc(boolean flag) { + prefs.putBoolean(KEY_USE_WEBRTC, flag); + } } diff --git a/src/main/java/net/rptools/maptool/server/ServerConfig.java b/src/main/java/net/rptools/maptool/server/ServerConfig.java index 1676c55635..fcba48fc7d 100644 --- a/src/main/java/net/rptools/maptool/server/ServerConfig.java +++ b/src/main/java/net/rptools/maptool/server/ServerConfig.java @@ -49,6 +49,7 @@ public class ServerConfig { private String serverName; private String hostName; private final boolean useEasyConnect; + private final boolean useWebRTC; public static String getPersonalServerGMPassword() { return personalServerGMPassword; @@ -62,6 +63,7 @@ public ServerConfig() { playerPassword = getPersonalServerPlayerPassword(); gmPassword = getPersonalServerGMPassword(); useEasyConnect = false; + useWebRTC = false; } public ServerConfig( @@ -71,7 +73,7 @@ public ServerConfig( int port, String serverName, String hostName) { - this(hostPlayerId, gmPassword, playerPassword, port, serverName, hostName, false); + this(hostPlayerId, gmPassword, playerPassword, port, serverName, hostName, false, false); } public ServerConfig( @@ -81,7 +83,8 @@ public ServerConfig( int port, String serverName, String hostName, - boolean useEasyConnect) { + boolean useEasyConnect, + boolean useWebRTC) { this.hostPlayerId = hostPlayerId; this.gmPassword = gmPassword; this.playerPassword = playerPassword; @@ -89,6 +92,7 @@ public ServerConfig( this.serverName = serverName; this.hostName = hostName; this.useEasyConnect = useEasyConnect; + this.useWebRTC = useWebRTC; } public String getHostPlayerId() { @@ -143,6 +147,10 @@ public boolean getUseEasyConnect() { return useEasyConnect; } + public boolean getUseWebRTC() { + return useWebRTC; + } + private static Random r = new Random(); private static int findOpenPort(int rangeLow, int rangeHigh) { diff --git a/src/main/java/net/rptools/maptool/server/ServerPolicy.java b/src/main/java/net/rptools/maptool/server/ServerPolicy.java index 9ba065c72b..2dc31ef2b7 100644 --- a/src/main/java/net/rptools/maptool/server/ServerPolicy.java +++ b/src/main/java/net/rptools/maptool/server/ServerPolicy.java @@ -20,7 +20,6 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import net.rptools.maptool.client.AppPreferences; -import net.rptools.maptool.client.AppState; import net.rptools.maptool.client.MapTool; import net.rptools.maptool.client.ui.StartServerDialogPreferences; import net.rptools.maptool.client.walker.WalkerMetric; @@ -288,9 +287,8 @@ public JsonObject toJSON() { sinfo.addProperty( "personal server", MapTool.isPersonalServer() ? BigDecimal.ONE : BigDecimal.ZERO); - sinfo.addProperty("useWebRTC", AppState.useWebRTC() ? BigDecimal.ONE : BigDecimal.ZERO); - StartServerDialogPreferences prefs = new StartServerDialogPreferences(); + sinfo.addProperty("useWebRTC", prefs.getUseWebRtc() ? BigDecimal.ONE : BigDecimal.ZERO); sinfo.addProperty( "usePasswordFile", prefs.getUsePasswordFile() ? BigDecimal.ONE : BigDecimal.ZERO); sinfo.addProperty("server name", prefs.getRPToolsName()); diff --git a/src/main/resources/net/rptools/maptool/client/ui/forms/connectToServerDialog.xml b/src/main/resources/net/rptools/maptool/client/ui/forms/connectToServerDialog.xml index fd591ec6f1..ca163288fe 100644 --- a/src/main/resources/net/rptools/maptool/client/ui/forms/connectToServerDialog.xml +++ b/src/main/resources/net/rptools/maptool/client/ui/forms/connectToServerDialog.xml @@ -24,8 +24,8 @@ com.jeta.forms.gui.form.FormComponent - /Users/cwisniew/Development/RPTools/maptool/src/main/resources/net/rptools/maptool/client/ui/forms/connectToServerDialog.xml - resources/net/rptools/maptool/client/ui/forms/connectToServerDialog.xml + C:\Users\tkunze\Source\maptool\src\main\resources\net\rptools\maptool\client\ui\forms\connectToServerDialog.xml + main\resources\net\rptools\maptool\client\ui\forms\connectToServerDialog.xml CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE FILL:DEFAULT:NONE,RIGHT:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE @@ -74,7 +74,7 @@ - 194 + 210 ConnectToServerDialog.username @@ -82,7 +82,7 @@ fill - 15 + 17 @@ -134,7 +134,7 @@ - 193 + 207 ConnectToServerDialog.password @@ -142,7 +142,7 @@ fill - 15 + 17 @@ -195,8 +195,8 @@ @username - 1202 - 21 + 959 + 23 @@ -249,8 +249,8 @@ @password - 1202 - 21 + 959 + 23 @@ -337,7 +337,7 @@ com.jeta.forms.gui.form.FormComponent - embedded.858886027 + embedded.1043041452 CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE @@ -386,7 +386,7 @@ - 209 + 225 ConnectToServerDialog.server.name @@ -394,7 +394,7 @@ fill - 15 + 17 @@ -448,9 +448,9 @@ Refresh refreshButton - 113 + 121 Button.refresh - 23 + 25 @@ -503,8 +503,8 @@ @serverName - 991 - 21 + 740 + 23 @@ -557,7 +557,7 @@ aliasTable - 1351 + 1124 scollBars @@ -717,7 +717,7 @@ com.jeta.forms.gui.form.FormComponent - embedded.2101283598 + embedded.1154831135 CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE @@ -766,7 +766,7 @@ - 1239 + 1004 ConnectToServerDialog.server.local @@ -774,7 +774,7 @@ fill - 15 + 17 @@ -829,7 +829,7 @@ true true localServerList - 1351 + 1124 items @@ -862,7 +862,7 @@ - 583 + 393 @@ -916,9 +916,9 @@ Rescan rescanButton - 110 + 118 Button.rescan - 23 + 25 @@ -1050,7 +1050,7 @@ com.jeta.forms.gui.form.FormComponent - embedded.769035931 + embedded.1813606542 CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:MAX(48DLU;DEFAULT):NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE @@ -1099,7 +1099,7 @@ - 224 + 239 ConnectToServerDialog.server.address @@ -1107,7 +1107,7 @@ fill - 15 + 17 @@ -1159,7 +1159,7 @@ - 224 + 239 ConnectToServerDialog.server.port @@ -1167,7 +1167,7 @@ fill - 15 + 17 @@ -1220,8 +1220,8 @@ @host - 1109 - 21 + 867 + 23 @@ -1276,7 +1276,7 @@ 5 @port 92 - 21 + 23 @@ -1384,9 +1384,9 @@ - 1416 + 1189 3 - 737 + 551 @@ -1440,66 +1440,9 @@ ConnectToServerDialog.usePublicKey @usePublicKey - 233 + 250 ConnectToServerDialog.usePublicKey - 17 - - - - - - - - - - - - - - 6 - 6 - 1 - 1 - default - default - 0,0,0,0 - - - com.jeta.forms.gui.form.StandardComponent - - com.jeta.forms.gui.beans.JETABean - javax.swing.JCheckBox - - - javax.swing.JCheckBox - - - - - - border - - - - - - - - border - - - - - - - - - ConnectToServerDialog.usePublicKey - @useWebRTC - 179 - WebRTC.toggleUseWebRTC - WebRTC.toggleUseWebRTC.tooltip - 17 + 19 @@ -1524,7 +1467,7 @@ com.jeta.forms.gui.form.FormComponent - embedded.477922296 + embedded.711296620 CENTER:DEFAULT:NONE FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE @@ -1575,9 +1518,9 @@ OK okButton - 86 + 91 Button.ok - 23 + 25 @@ -1631,9 +1574,9 @@ JButton cancelButton - 108 + 117 Button.cancel - 23 + 25 @@ -1740,7 +1683,7 @@ - + fill From dc2b70d820e7364090b85a9d1f4807cd1626d6d0 Mon Sep 17 00:00:00 2001 From: Thomas Kunze Date: Sat, 29 Oct 2022 22:28:58 +0200 Subject: [PATCH 3/6] cope with serverregistry returning webrtc as int. --- src/main/java/net/rptools/maptool/client/AppActions.java | 3 ++- .../java/net/rptools/maptool/client/MapToolRegistry.java | 2 +- .../net/rptools/maptool/client/ui/ConnectToServerDialog.java | 4 ++++ src/main/java/net/rptools/maptool/server/ServerConfig.java | 5 +++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/AppActions.java b/src/main/java/net/rptools/maptool/client/AppActions.java index c3c91ff45d..34342387e3 100644 --- a/src/main/java/net/rptools/maptool/client/AppActions.java +++ b/src/main/java/net/rptools/maptool/client/AppActions.java @@ -2426,7 +2426,8 @@ protected void executeAction() { "", dialog.getPort(), prefs.getServerName(), - dialog.getServer()); + dialog.getServer(), + dialog.getUseWebRTC()); String password = prefs.getUsePublicKey() diff --git a/src/main/java/net/rptools/maptool/client/MapToolRegistry.java b/src/main/java/net/rptools/maptool/client/MapToolRegistry.java index fec8746876..3d432387ce 100644 --- a/src/main/java/net/rptools/maptool/client/MapToolRegistry.java +++ b/src/main/java/net/rptools/maptool/client/MapToolRegistry.java @@ -94,7 +94,7 @@ public SeverConnectionDetails findInstance(String id) { details.address = json.getAsJsonPrimitive("address").getAsString(); details.port = json.getAsJsonPrimitive("port").getAsInt(); - details.webrtc = json.getAsJsonPrimitive("webrtc").getAsBoolean(); + details.webrtc = json.getAsJsonPrimitive("webrtc").getAsInt() > 0; // .getAsBoolean(); return details; diff --git a/src/main/java/net/rptools/maptool/client/ui/ConnectToServerDialog.java b/src/main/java/net/rptools/maptool/client/ui/ConnectToServerDialog.java index 2737e9fd5e..559f62a4a2 100644 --- a/src/main/java/net/rptools/maptool/client/ui/ConnectToServerDialog.java +++ b/src/main/java/net/rptools/maptool/client/ui/ConnectToServerDialog.java @@ -81,6 +81,10 @@ public String getServer() { return connectionDetails.address; } + public boolean getUseWebRTC() { + return connectionDetails.webrtc; + } + public void showDialog() { dialog = new GenericDialog( diff --git a/src/main/java/net/rptools/maptool/server/ServerConfig.java b/src/main/java/net/rptools/maptool/server/ServerConfig.java index fcba48fc7d..dfbf929f77 100644 --- a/src/main/java/net/rptools/maptool/server/ServerConfig.java +++ b/src/main/java/net/rptools/maptool/server/ServerConfig.java @@ -72,8 +72,9 @@ public ServerConfig( String playerPassword, int port, String serverName, - String hostName) { - this(hostPlayerId, gmPassword, playerPassword, port, serverName, hostName, false, false); + String hostName, + boolean useWebRTC) { + this(hostPlayerId, gmPassword, playerPassword, port, serverName, hostName, false, useWebRTC); } public ServerConfig( From f2f44e8aeaf33005531e7f88e08c98edf9fcf43b Mon Sep 17 00:00:00 2001 From: Thomas Kunze Date: Mon, 26 Dec 2022 14:02:15 +0100 Subject: [PATCH 4/6] check for type of webrtc property from mt registry, bump webrtc lib version --- build.gradle | 8 ++++---- .../net/rptools/maptool/client/MapToolRegistry.java | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 6f3aa810c6..ae7a3a0a29 100644 --- a/build.gradle +++ b/build.gradle @@ -423,13 +423,13 @@ dependencies { // webrtc implementation group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.2' - implementation 'dev.onvoid.webrtc:webrtc-java:0.5.0' + implementation 'dev.onvoid.webrtc:webrtc-java:0.7.0' if (osdetector.os.is('windows')) - implementation 'dev.onvoid.webrtc:webrtc-java:0.5.0:windows-x86_64' + implementation 'dev.onvoid.webrtc:webrtc-java:0.7.0:windows-x86_64' else if (osdetector.os.is('osx')) - implementation 'dev.onvoid.webrtc:webrtc-java:0.5.0:macos-x86_64' + implementation 'dev.onvoid.webrtc:webrtc-java:0.7.0:macos-x86_64' else if (osdetector.os.is('linux')) - implementation 'dev.onvoid.webrtc:webrtc-java:0.5.0:linux-x86_64' + implementation 'dev.onvoid.webrtc:webrtc-java:0.7.0:linux-x86_64' // protobuf implementation "io.grpc:grpc-protobuf:1.47.0" diff --git a/src/main/java/net/rptools/maptool/client/MapToolRegistry.java b/src/main/java/net/rptools/maptool/client/MapToolRegistry.java index 3d432387ce..6f21ef9e2c 100644 --- a/src/main/java/net/rptools/maptool/client/MapToolRegistry.java +++ b/src/main/java/net/rptools/maptool/client/MapToolRegistry.java @@ -94,7 +94,16 @@ public SeverConnectionDetails findInstance(String id) { details.address = json.getAsJsonPrimitive("address").getAsString(); details.port = json.getAsJsonPrimitive("port").getAsInt(); - details.webrtc = json.getAsJsonPrimitive("webrtc").getAsInt() > 0; // .getAsBoolean(); + + // currently the webrtc property is sent as int. In the future this will + // change to boolean. So we check what the type is. Can be removed when + // we get it as boolean. + var webrtcProperty = json.getAsJsonPrimitive("webrtc"); + if(webrtcProperty.isBoolean()) { + details.webrtc = webrtcProperty.getAsBoolean(); + } else { + details.webrtc = webrtcProperty.getAsInt() > 0; + } return details; From f32c8493ca754a893ba3301a5310180b213d3aa0 Mon Sep 17 00:00:00 2001 From: Thomas Kunze Date: Mon, 26 Dec 2022 14:09:59 +0100 Subject: [PATCH 5/6] spotless --- src/main/java/net/rptools/maptool/client/MapToolRegistry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/rptools/maptool/client/MapToolRegistry.java b/src/main/java/net/rptools/maptool/client/MapToolRegistry.java index 6f21ef9e2c..608b914ca9 100644 --- a/src/main/java/net/rptools/maptool/client/MapToolRegistry.java +++ b/src/main/java/net/rptools/maptool/client/MapToolRegistry.java @@ -99,7 +99,7 @@ public SeverConnectionDetails findInstance(String id) { // change to boolean. So we check what the type is. Can be removed when // we get it as boolean. var webrtcProperty = json.getAsJsonPrimitive("webrtc"); - if(webrtcProperty.isBoolean()) { + if (webrtcProperty.isBoolean()) { details.webrtc = webrtcProperty.getAsBoolean(); } else { details.webrtc = webrtcProperty.getAsInt() > 0; From ad5368cbb4680c46843dbcdf940943325ebe7cfe Mon Sep 17 00:00:00 2001 From: Thomas Kunze Date: Mon, 26 Dec 2022 21:11:17 +0100 Subject: [PATCH 6/6] i18n --- .../clientserver/simple/client/WebRTCClientConnection.java | 2 +- .../clientserver/simple/server/WebRTCServerConnection.java | 2 +- src/main/resources/net/rptools/maptool/language/i18n.properties | 1 + .../resources/net/rptools/maptool/language/i18n_de.properties | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/rptools/clientserver/simple/client/WebRTCClientConnection.java b/src/main/java/net/rptools/clientserver/simple/client/WebRTCClientConnection.java index 85d614bdf9..f54d1d6e5f 100644 --- a/src/main/java/net/rptools/clientserver/simple/client/WebRTCClientConnection.java +++ b/src/main/java/net/rptools/clientserver/simple/client/WebRTCClientConnection.java @@ -275,7 +275,7 @@ public void onFailure(String error) { private void onLogin(LoginMessageDto message) { if (!message.success) { - MapTool.showError("Player already taken!"); + MapTool.showError("Handshake.msg.playerAlreadyConnected"); return; } diff --git a/src/main/java/net/rptools/clientserver/simple/server/WebRTCServerConnection.java b/src/main/java/net/rptools/clientserver/simple/server/WebRTCServerConnection.java index 79188eb3bb..635a81f208 100644 --- a/src/main/java/net/rptools/clientserver/simple/server/WebRTCServerConnection.java +++ b/src/main/java/net/rptools/clientserver/simple/server/WebRTCServerConnection.java @@ -108,7 +108,7 @@ private void handleSignalingMessage(String message) { case "login" -> { var loginMsg = gson.fromJson(message, LoginMessageDto.class); if (!loginMsg.success) { - MapTool.showError("Servername already taken!"); + MapTool.showError("ServerDialog.error.serverAlreadyExists"); } } case "offer" -> { diff --git a/src/main/resources/net/rptools/maptool/language/i18n.properties b/src/main/resources/net/rptools/maptool/language/i18n.properties index a866cf5ff7..14fa14c9d0 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n.properties @@ -697,6 +697,7 @@ ServerDialog.error.passwordMissing = Both Player and GM Password must be pro ServerDialog.error.playerPasswordMissing = Player Password must be provided. ServerDialog.error.gmPasswordMissing = GM Password must be provided. ServerDialog.error.passwordMustDiffer = Player and GM Password can not be the same. +ServerDialog.error.serverAlreadyExists = A server with the same name already exists. # The connection test has been disabled so these are not currently used. ServerDialog.msg.test1 = Setting Up For Connection Test... diff --git a/src/main/resources/net/rptools/maptool/language/i18n_de.properties b/src/main/resources/net/rptools/maptool/language/i18n_de.properties index f2c73a9e92..f3cdabf438 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n_de.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n_de.properties @@ -697,7 +697,7 @@ ServerDialog.error.passwordMissing = Sowohl Spieler- als auch SL-Passwort m ServerDialog.error.playerPasswordMissing = Spieler-Passwort muss angegeben werden. ServerDialog.error.gmPasswordMissing = SL-Passwort muss angegeben werden. ServerDialog.error.passwordMustDiffer = Spieler- und SL-Passwort dürfen nicht identisch sein. - +ServerDialog.error.serverAlreadyExists=Ein Server mit diesem Namen existiert bereits. # The connection test has been disabled so these are not currently used. ServerDialog.msg.test1 = Einrichten für den Verbindungstest... ServerDialog.msg.test2 = Verbindungstest ausführen. Erfolg ist normalerweise schnell; Misserfolg dauert meist länger...