Skip to content

More client lifecycle improvements - #4777

Merged
cwisniew merged 6 commits into
RPTools:developfrom
kwvanderlinde:bugfix/4776-heartbeat-interleaved-with-handshake
May 20, 2024
Merged

More client lifecycle improvements#4777
cwisniew merged 6 commits into
RPTools:developfrom
kwvanderlinde:bugfix/4776-heartbeat-interleaved-with-handshake

Conversation

@kwvanderlinde

@kwvanderlinde kwvanderlinde commented May 11, 2024

Copy link
Copy Markdown
Collaborator

Identify the Bug or Feature request

Fixes #4776, follow up to PR #4771

Description of the Change

The main change here is the bug fix for #4776: ServerCommand will now only send messages if the client has finished its handshake. This is done by giving MapToolClient an explicit set of states: New when first created; Started after the handshake is started on a New client;Connected when the handshake completes for a Started client; Closed whenever close() is called regardless of previous state.

Second is that handshakes are future-based now which really cleans up the amount of code dedicated to observer them and getting results.

Third is some minor fixes and clean up related to the player database UI.

Possible Drawbacks

Hopefully none ...

Documentation Notes

N/A

Release Notes

N/A


This change is Reviewable

@kwvanderlinde kwvanderlinde self-assigned this May 11, 2024
@kwvanderlinde
kwvanderlinde marked this pull request as draft May 13, 2024 07:38
@kwvanderlinde
kwvanderlinde force-pushed the bugfix/4776-heartbeat-interleaved-with-handshake branch 10 times, most recently from 336e8bc to 0f06a23 Compare May 14, 2024 07:21
Otherwise there is a timing bug where if the client happens to respond quickly and the handshake thread happens to be
suspended between sending the message and setting the state.
This removes the need for `HandshakeObserver` as well as most methods on `Handshake`, since the information can now be
obtained through the future results.

Handshakes also register and unregister themselves as message handlers. This removes the need for `releaseHandshake()`,
as well as for `MapToolServerConnection` to keep track of handshakes.
@kwvanderlinde
kwvanderlinde force-pushed the bugfix/4776-heartbeat-interleaved-with-handshake branch 2 times, most recently from 08e8b3e to e9f8422 Compare May 14, 2024 07:51
@kwvanderlinde
kwvanderlinde marked this pull request as ready for review May 14, 2024 07:54
@kwvanderlinde
kwvanderlinde force-pushed the bugfix/4776-heartbeat-interleaved-with-handshake branch 3 times, most recently from 3d34660 to 2e92e1e Compare May 16, 2024 23:14
The client can now be in one of these states: `New`; `Started`; `Connected`; `Closed`. When transitioning states, we
check that we are in an acceptable state or otherwise disallow the transition. This ensures that calls like `start()` or
`stop()` can only be effected once.

ServerCommandClientImpl will now avoid sending messages unless the client state is `Connected`. Among other things, this
prevents unwanted heartbeats from being sent during handshakes.
Instead, the sole observable player database (`PasswordFilePlayerDatabase`) will fire these
events. `PlayerDatabaseDialogController` is the only listener and now registers directly on the database.

The public API of `Players` has also been reduced, either by privatizing methods or removing trivial wrappers of its
player database.
@kwvanderlinde
kwvanderlinde force-pushed the bugfix/4776-heartbeat-interleaved-with-handshake branch from 2e92e1e to 49b9254 Compare May 16, 2024 23:16
@kwvanderlinde

Copy link
Copy Markdown
Collaborator Author

I've pared this down to the more essential stuff. I'll do a follow-up PR afteward that really streamlines server init in general.

Comment thread src/main/java/net/rptools/maptool/server/ServerHandshake.java Outdated

@thelsing thelsing left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM beside the one typo.

@cwisniew
cwisniew added this pull request to the merge queue May 19, 2024
Merged via the queue into RPTools:develop with commit b7117da May 20, 2024
@kwvanderlinde
kwvanderlinde deleted the bugfix/4776-heartbeat-interleaved-with-handshake branch May 20, 2024 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

No open projects
Status: Merged

Development

Successfully merging this pull request may close these issues.

[Bug]: Ill-timed heartbearts cause handshake failures

3 participants