More client lifecycle improvements - #4777
Merged
cwisniew merged 6 commits intoMay 20, 2024
Merged
Conversation
kwvanderlinde
marked this pull request as draft
May 13, 2024 07:38
kwvanderlinde
force-pushed
the
bugfix/4776-heartbeat-interleaved-with-handshake
branch
10 times, most recently
from
May 14, 2024 07:21
336e8bc to
0f06a23
Compare
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
force-pushed
the
bugfix/4776-heartbeat-interleaved-with-handshake
branch
2 times, most recently
from
May 14, 2024 07:51
08e8b3e to
e9f8422
Compare
kwvanderlinde
marked this pull request as ready for review
May 14, 2024 07:54
kwvanderlinde
force-pushed
the
bugfix/4776-heartbeat-interleaved-with-handshake
branch
3 times, most recently
from
May 16, 2024 23:14
3d34660 to
2e92e1e
Compare
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
force-pushed
the
bugfix/4776-heartbeat-interleaved-with-handshake
branch
from
May 16, 2024 23:16
2e92e1e to
49b9254
Compare
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. |
thelsing
reviewed
May 17, 2024
thelsing
approved these changes
May 17, 2024
thelsing
left a comment
Collaborator
There was a problem hiding this comment.
LGTM beside the one typo.
kwvanderlinde
deleted the
bugfix/4776-heartbeat-interleaved-with-handshake
branch
May 20, 2024 04:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
ServerCommandwill now only send messages if the client has finished its handshake. This is done by givingMapToolClientan explicit set of states:Newwhen first created;Startedafter the handshake is started on aNewclient;Connectedwhen the handshake completes for aStartedclient;Closedwheneverclose()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