From 20c9ce1e970e0e4ba34025814cfcb738912607cc Mon Sep 17 00:00:00 2001 From: Kenneth VanderLinde Date: Fri, 5 Apr 2024 14:11:08 -0700 Subject: [PATCH] Move clientserver code into a subproject Left behind was `ConnectionFactory` as it is really a MapTool-specific tool for building connections and servers rather than a part of the general client-server logic itself. Also pulled in was `Handshake` and `HandshakeObserver` since they are used in the client-server and are an important part of the process (the implementations were left behind though). Dependencies specific to clientserver were moved out of the root project into the new subproject. --- build.gradle | 15 +----- clientserver/build.gradle | 50 +++++++++++++++++++ .../clientserver/ActivityListener.java | 0 .../simple/DisconnectHandler.java | 0 .../clientserver/simple}/Handshake.java | 2 +- .../simple}/HandshakeObserver.java | 2 +- .../clientserver/simple/MessageHandler.java | 0 .../simple/connection/AbstractConnection.java | 0 .../simple/connection/Connection.java | 0 .../simple/connection/SocketConnection.java | 0 .../simple/connection/WebRTCConnection.java | 0 .../simple/server/AbstractServer.java | 4 +- .../simple/server/HandshakeProvider.java | 2 +- .../clientserver/simple/server/Server.java | 0 .../simple/server/ServerObserver.java | 0 .../simple/server/SocketServer.java | 0 .../simple/server/WebRTCServer.java | 0 .../simple/webrtc/AnswerMessageDto.java | 0 .../simple/webrtc/CandidateMessageDto.java | 0 .../simple/webrtc/LoginMessageDto.java | 0 .../simple/webrtc/MessageDto.java | 0 .../simple/webrtc/OfferMessageDto.java | 0 settings.gradle | 1 + .../maptool/server/ClientHandshake.java | 2 + .../server/MapToolServerConnection.java | 2 + .../maptool/server/ServerHandshake.java | 2 + 26 files changed, 64 insertions(+), 18 deletions(-) create mode 100644 clientserver/build.gradle rename {src => clientserver/src}/main/java/net/rptools/clientserver/ActivityListener.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/DisconnectHandler.java (100%) rename {src/main/java/net/rptools/maptool/server => clientserver/src/main/java/net/rptools/clientserver/simple}/Handshake.java (98%) rename {src/main/java/net/rptools/maptool/server => clientserver/src/main/java/net/rptools/clientserver/simple}/HandshakeObserver.java (94%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/MessageHandler.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/connection/AbstractConnection.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/connection/Connection.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/connection/SocketConnection.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/connection/WebRTCConnection.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/server/AbstractServer.java (97%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/server/HandshakeProvider.java (94%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/server/Server.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/server/ServerObserver.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/server/SocketServer.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/server/WebRTCServer.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/webrtc/AnswerMessageDto.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/webrtc/CandidateMessageDto.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/webrtc/LoginMessageDto.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/webrtc/MessageDto.java (100%) rename {src => clientserver/src}/main/java/net/rptools/clientserver/simple/webrtc/OfferMessageDto.java (100%) diff --git a/build.gradle b/build.gradle index 9d2768a141..49a4e3332e 100644 --- a/build.gradle +++ b/build.gradle @@ -342,6 +342,8 @@ repositories { dependencies { forms group: 'com.jetbrains.intellij.java', name: 'java-compiler-ant-tasks', version: '233.14475.56' + implementation project(':clientserver') + implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.22.1' implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.22.1' implementation group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '2.20.0' // Bridges v1 to v2 for other code in other libs @@ -492,16 +494,6 @@ dependencies { // Noise Generator implementation 'com.github.cwisniew:NoiseLib:1.0.0' // The most recent version, 1.0.0 is build for a later java version: major version 55 is newer than 54, the highest major version supported by this compiler - // webrtc - implementation group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.6' - implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0' - if (osdetector.os.is('windows')) - implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0:windows-x86_64' - else if (osdetector.os.is('osx')) - implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0:macos-x86_64' - else if (osdetector.os.is('linux')) - implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0:linux-x86_64' - // protobuf implementation "io.grpc:grpc-protobuf:1.61.1" implementation "com.google.protobuf:protobuf-java-util:3.25.2" @@ -516,9 +508,6 @@ dependencies { implementation 'org.jsoup:jsoup:1.17.2' // eventbus implementation 'com.google.guava:guava:33.0.0-jre' - // compression of messages between client and server - implementation 'org.apache.commons:commons-compress:1.26.0' - implementation 'com.github.luben:zstd-jni:1.5.5-11' // intellij forms runtime implementation 'com.jetbrains.intellij.java:java-gui-forms-rt:241.12019' // layout for forms created in code diff --git a/clientserver/build.gradle b/clientserver/build.gradle new file mode 100644 index 0000000000..255ddc6569 --- /dev/null +++ b/clientserver/build.gradle @@ -0,0 +1,50 @@ +buildscript { + repositories { + mavenCentral() + } + dependencies { + } +} + +plugins { + id "base" + id "java-library" +} + +// In this section you declare where to find the dependencies of your project +repositories { + mavenLocal() + mavenCentral() + maven { url = 'https://maptool.craigs-stuff.net/repo/' } + maven { url = 'https://jitpack.io' } + maven { url "https://www.jetbrains.com/intellij-repository/releases" } + maven { url "https://cache-redirector.jetbrains.com/intellij-dependencies" } +} + + +// In this section you declare the dependencies for your production and test code +dependencies { + implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.22.1' + implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.22.1' + implementation group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '2.20.0' // Bridges v1 to v2 for other code in other libs + implementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.12' + implementation group: 'commons-logging', name: 'commons-logging', version: '1.3.0' + + // Better JSON functions... + implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1' // https://mvnrepository.com/artifact/com.google.code.gson/gson + + // webrtc + implementation group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.6' + // Needs to be API since WebRTCConnection implements PeerConnectionObserver and RTCDataChannelObserver. + implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0' + if (osdetector.os.is('windows')) + implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0:windows-x86_64' + else if (osdetector.os.is('osx')) + implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0:macos-x86_64' + else if (osdetector.os.is('linux')) + implementation 'dev.onvoid.webrtc:webrtc-java:0.8.0:linux-x86_64' + + // compression of messages between client and server + implementation 'org.apache.commons:commons-compress:1.26.0' + implementation 'com.github.luben:zstd-jni:1.5.5-11' +} diff --git a/src/main/java/net/rptools/clientserver/ActivityListener.java b/clientserver/src/main/java/net/rptools/clientserver/ActivityListener.java similarity index 100% rename from src/main/java/net/rptools/clientserver/ActivityListener.java rename to clientserver/src/main/java/net/rptools/clientserver/ActivityListener.java diff --git a/src/main/java/net/rptools/clientserver/simple/DisconnectHandler.java b/clientserver/src/main/java/net/rptools/clientserver/simple/DisconnectHandler.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/DisconnectHandler.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/DisconnectHandler.java diff --git a/src/main/java/net/rptools/maptool/server/Handshake.java b/clientserver/src/main/java/net/rptools/clientserver/simple/Handshake.java similarity index 98% rename from src/main/java/net/rptools/maptool/server/Handshake.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/Handshake.java index de62e94160..72a6b7d5b1 100644 --- a/src/main/java/net/rptools/maptool/server/Handshake.java +++ b/clientserver/src/main/java/net/rptools/clientserver/simple/Handshake.java @@ -12,7 +12,7 @@ * and specifically the Affero license * text at . */ -package net.rptools.maptool.server; +package net.rptools.clientserver.simple; import java.util.concurrent.ExecutionException; import net.rptools.clientserver.simple.connection.Connection; diff --git a/src/main/java/net/rptools/maptool/server/HandshakeObserver.java b/clientserver/src/main/java/net/rptools/clientserver/simple/HandshakeObserver.java similarity index 94% rename from src/main/java/net/rptools/maptool/server/HandshakeObserver.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/HandshakeObserver.java index e8e62d66a0..e81393ba56 100644 --- a/src/main/java/net/rptools/maptool/server/HandshakeObserver.java +++ b/clientserver/src/main/java/net/rptools/clientserver/simple/HandshakeObserver.java @@ -12,7 +12,7 @@ * and specifically the Affero license * text at . */ -package net.rptools.maptool.server; +package net.rptools.clientserver.simple; public interface HandshakeObserver { diff --git a/src/main/java/net/rptools/clientserver/simple/MessageHandler.java b/clientserver/src/main/java/net/rptools/clientserver/simple/MessageHandler.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/MessageHandler.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/MessageHandler.java diff --git a/src/main/java/net/rptools/clientserver/simple/connection/AbstractConnection.java b/clientserver/src/main/java/net/rptools/clientserver/simple/connection/AbstractConnection.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/connection/AbstractConnection.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/connection/AbstractConnection.java diff --git a/src/main/java/net/rptools/clientserver/simple/connection/Connection.java b/clientserver/src/main/java/net/rptools/clientserver/simple/connection/Connection.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/connection/Connection.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/connection/Connection.java diff --git a/src/main/java/net/rptools/clientserver/simple/connection/SocketConnection.java b/clientserver/src/main/java/net/rptools/clientserver/simple/connection/SocketConnection.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/connection/SocketConnection.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/connection/SocketConnection.java diff --git a/src/main/java/net/rptools/clientserver/simple/connection/WebRTCConnection.java b/clientserver/src/main/java/net/rptools/clientserver/simple/connection/WebRTCConnection.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/connection/WebRTCConnection.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/connection/WebRTCConnection.java diff --git a/src/main/java/net/rptools/clientserver/simple/server/AbstractServer.java b/clientserver/src/main/java/net/rptools/clientserver/simple/server/AbstractServer.java similarity index 97% rename from src/main/java/net/rptools/clientserver/simple/server/AbstractServer.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/server/AbstractServer.java index b966028f2a..e93376b8b5 100644 --- a/src/main/java/net/rptools/clientserver/simple/server/AbstractServer.java +++ b/clientserver/src/main/java/net/rptools/clientserver/simple/server/AbstractServer.java @@ -17,10 +17,10 @@ import java.util.*; import java.util.concurrent.ExecutionException; import net.rptools.clientserver.simple.DisconnectHandler; +import net.rptools.clientserver.simple.Handshake; +import net.rptools.clientserver.simple.HandshakeObserver; import net.rptools.clientserver.simple.MessageHandler; import net.rptools.clientserver.simple.connection.Connection; -import net.rptools.maptool.server.Handshake; -import net.rptools.maptool.server.HandshakeObserver; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/net/rptools/clientserver/simple/server/HandshakeProvider.java b/clientserver/src/main/java/net/rptools/clientserver/simple/server/HandshakeProvider.java similarity index 94% rename from src/main/java/net/rptools/clientserver/simple/server/HandshakeProvider.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/server/HandshakeProvider.java index e9444833fb..1a073ce58a 100644 --- a/src/main/java/net/rptools/clientserver/simple/server/HandshakeProvider.java +++ b/clientserver/src/main/java/net/rptools/clientserver/simple/server/HandshakeProvider.java @@ -14,8 +14,8 @@ */ package net.rptools.clientserver.simple.server; +import net.rptools.clientserver.simple.Handshake; import net.rptools.clientserver.simple.connection.Connection; -import net.rptools.maptool.server.Handshake; public interface HandshakeProvider { Handshake getConnectionHandshake(Connection conn); diff --git a/src/main/java/net/rptools/clientserver/simple/server/Server.java b/clientserver/src/main/java/net/rptools/clientserver/simple/server/Server.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/server/Server.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/server/Server.java diff --git a/src/main/java/net/rptools/clientserver/simple/server/ServerObserver.java b/clientserver/src/main/java/net/rptools/clientserver/simple/server/ServerObserver.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/server/ServerObserver.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/server/ServerObserver.java diff --git a/src/main/java/net/rptools/clientserver/simple/server/SocketServer.java b/clientserver/src/main/java/net/rptools/clientserver/simple/server/SocketServer.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/server/SocketServer.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/server/SocketServer.java diff --git a/src/main/java/net/rptools/clientserver/simple/server/WebRTCServer.java b/clientserver/src/main/java/net/rptools/clientserver/simple/server/WebRTCServer.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/server/WebRTCServer.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/server/WebRTCServer.java diff --git a/src/main/java/net/rptools/clientserver/simple/webrtc/AnswerMessageDto.java b/clientserver/src/main/java/net/rptools/clientserver/simple/webrtc/AnswerMessageDto.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/webrtc/AnswerMessageDto.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/webrtc/AnswerMessageDto.java diff --git a/src/main/java/net/rptools/clientserver/simple/webrtc/CandidateMessageDto.java b/clientserver/src/main/java/net/rptools/clientserver/simple/webrtc/CandidateMessageDto.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/webrtc/CandidateMessageDto.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/webrtc/CandidateMessageDto.java diff --git a/src/main/java/net/rptools/clientserver/simple/webrtc/LoginMessageDto.java b/clientserver/src/main/java/net/rptools/clientserver/simple/webrtc/LoginMessageDto.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/webrtc/LoginMessageDto.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/webrtc/LoginMessageDto.java diff --git a/src/main/java/net/rptools/clientserver/simple/webrtc/MessageDto.java b/clientserver/src/main/java/net/rptools/clientserver/simple/webrtc/MessageDto.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/webrtc/MessageDto.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/webrtc/MessageDto.java diff --git a/src/main/java/net/rptools/clientserver/simple/webrtc/OfferMessageDto.java b/clientserver/src/main/java/net/rptools/clientserver/simple/webrtc/OfferMessageDto.java similarity index 100% rename from src/main/java/net/rptools/clientserver/simple/webrtc/OfferMessageDto.java rename to clientserver/src/main/java/net/rptools/clientserver/simple/webrtc/OfferMessageDto.java diff --git a/settings.gradle b/settings.gradle index bd472eecbf..440cc0f959 100644 --- a/settings.gradle +++ b/settings.gradle @@ -16,3 +16,4 @@ include 'services:webservice' */ rootProject.name = 'MapTool' +include ':clientserver' \ No newline at end of file diff --git a/src/main/java/net/rptools/maptool/server/ClientHandshake.java b/src/main/java/net/rptools/maptool/server/ClientHandshake.java index 13e88dcb67..9531280dbc 100644 --- a/src/main/java/net/rptools/maptool/server/ClientHandshake.java +++ b/src/main/java/net/rptools/maptool/server/ClientHandshake.java @@ -31,6 +31,8 @@ import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.swing.*; +import net.rptools.clientserver.simple.Handshake; +import net.rptools.clientserver.simple.HandshakeObserver; import net.rptools.clientserver.simple.MessageHandler; import net.rptools.clientserver.simple.connection.Connection; import net.rptools.lib.MD5Key; diff --git a/src/main/java/net/rptools/maptool/server/MapToolServerConnection.java b/src/main/java/net/rptools/maptool/server/MapToolServerConnection.java index ff06af540f..edd1a31cd5 100644 --- a/src/main/java/net/rptools/maptool/server/MapToolServerConnection.java +++ b/src/main/java/net/rptools/maptool/server/MapToolServerConnection.java @@ -18,6 +18,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import net.rptools.clientserver.ConnectionFactory; +import net.rptools.clientserver.simple.Handshake; +import net.rptools.clientserver.simple.HandshakeObserver; import net.rptools.clientserver.simple.connection.Connection; import net.rptools.clientserver.simple.server.HandshakeProvider; import net.rptools.clientserver.simple.server.Server; diff --git a/src/main/java/net/rptools/maptool/server/ServerHandshake.java b/src/main/java/net/rptools/maptool/server/ServerHandshake.java index ebf3314a5f..76b5cfb5a0 100644 --- a/src/main/java/net/rptools/maptool/server/ServerHandshake.java +++ b/src/main/java/net/rptools/maptool/server/ServerHandshake.java @@ -29,6 +29,8 @@ import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.swing.SwingUtilities; +import net.rptools.clientserver.simple.Handshake; +import net.rptools.clientserver.simple.HandshakeObserver; import net.rptools.clientserver.simple.MessageHandler; import net.rptools.clientserver.simple.connection.Connection; import net.rptools.lib.MD5Key;