Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move clientserver package into a new subproject #4751

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Apr 7, 2024

Identify the Bug or Feature request

First step on #3777

Description of the Change

This moves almost the entirety of the clientserver package into a new clientserver subproject. A bit of work was need to avoid certain references to outside of clientserver, but it's mostly mechanical transformation.

These seem are the main things to call out:

  • Handshake and HandshakeObserver are now part of clientserver as they were part of its interface already, just located elsewhere.
  • WebRTCConnection no longer directly implements the PeerConnectionObserver and RTCDataChannelObserver interfaces, instead providing nested classes for that. Without this change, the clientserver project would have to leak its dependency on the webrtc library.
  • In WebRTCConnection and WebRTCServer, rather than require a MapTool ServerPolicy we now require just a String server name, since that was all that was needed.
  • Also in WebRTCConnection and WebRTCServer, there were direct references to the MapTool class in a couple of error handling cases. To avoid this dependency, I added Listener interfaces to both so the main project can instead provide these calls. I don't especially like this, but I don't think it's worth trying to find a better solution in this PR. I have some more general ideas for reworking client & server code that would allow better handling of these cases, but that will be its own thing.

The only thing left behind in the main project was ConnectionFactory since that is really MapTool-specific logic rather than a part of the generic clientserver code.

Possible Drawbacks

Should be none, functionality is identical.

Documentation Notes

N/A

Release Notes

  • Refactored clientserver library into a subproject.

This change is Reviewable

@kwvanderlinde kwvanderlinde added the code-maintenance Adding/editing javadocs, unit tests, formatting. label Apr 7, 2024
@kwvanderlinde kwvanderlinde changed the title Minimize Handshake interface Move clientserver package into a new subproject Apr 7, 2024
@kwvanderlinde kwvanderlinde marked this pull request as draft April 9, 2024 04:19
@kwvanderlinde kwvanderlinde force-pushed the refactor/3777-separate-client-server-project branch from 20c9ce1 to 50f09bc Compare April 9, 2024 04:57
@kwvanderlinde kwvanderlinde marked this pull request as ready for review April 9, 2024 05:08
Since the clientserver code does not understand what a `Player` is, we can't have `Handshake.getPlayer()`. Since this
method is only used called on `ServerHandshake`, the method has been moved there and removed from `Handshake` and
`ClientHandshake`.

Additionally, the `Handshake` interface does not need to inherit from `MessageHandler`. Implementations can be
`MessageHandler` if they need to be (and they current do), but nothing about the handshake process inherently requires
this to be true.
Both `WebRTCConnection` and `WebRTCServer` have had the following changes made:
1. Instead of accepting a `ServerConfig`, they both accept a `String` server name. This was the only part of the config
   used in the WebRTC code.
2. Instead of calling `MapTool.stopServer()` and `MapTool.showError()`, they now both have `Listener` interfaces that
   communicate the events that needed these actions take. The `ConnectionFactory` is responsible for hooking these up to
   the `MapTool` methods. I'm not a big fan of this approach, but I wanted to avoid complete reworks of server
   initialization and connection management, so this is what I went with.

Also a bunch of `if` statements were gifted braces.
This avoids putting `PeerConnectionObserver` and `RTCDataChannelObserver` in the API of `WebRTCConnection`. Not doing
this will require subtle dependency requirements once in a separate project.
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).

Common build configurations wered moved into a `shared.gradle` file applied to the root project and
subprojects. Dependencies specific to the clientserver subproject were moved out of the root project to keep things
clear.
@kwvanderlinde kwvanderlinde force-pushed the refactor/3777-separate-client-server-project branch from 50f09bc to dca7107 Compare April 15, 2024 22:23
@cwisniew cwisniew added this pull request to the merge queue Apr 16, 2024
Merged via the queue into RPTools:develop with commit 7069d16 Apr 16, 2024
4 checks passed
@kwvanderlinde kwvanderlinde deleted the refactor/3777-separate-client-server-project branch April 16, 2024 13:03
@kwvanderlinde kwvanderlinde self-assigned this Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-maintenance Adding/editing javadocs, unit tests, formatting.
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

2 participants