Skip to content

Conversation

@jhobz
Copy link
Contributor

@jhobz jhobz commented Mar 11, 2022

LiveSplit.Server is not guaranteed to respond to messages in the same order they are received. This change uses the "nonce" field in the new JSON messaging standard to provide a unique identifier against which to match incoming and outgoing messages.

Currently, the class member this._openRequests added by this change is not actually used for anything. But it does provide a useful method for investigating errors or commands that never receive a response.

It also may be desired in the future to change the listening behavior of this library to use a single listener that looks up the appropriate Promise resolver in this._openRequests instead of the current behavior -- subscribing a new listener for every message. Another alternative would be to extend EventEmitter2 instead of EventEmitter, which would allow for namespacing events and subscribing listeners to only events emitted with their nonce. But as this would create a new dependency and be a larger change, I felt it made more sense to make the simpler change first.

Note that this PR depends on #6.

jhobz added 4 commits March 9, 2022 13:05
This is to coincide with a change to the LiveSplit.Server repo
At very fast polling intervals, the socket will sometimes send more than
one message from the server in a single 'data' event. This change
gracefully handles these edge cases, resulting in successful tests at as
fast as polling every 5ms.
LiveSplit.Server is not guaranteed to respond to messages in the same
order they are received. This change uses the "nonce" field in the new
JSON messaging standard to provide a unique identifier against which to
match incoming and outgoing messages.

Currently, `this._openRequests` is not actually used for anything. But
it does provide a useful method for investigating errors or commands
that never receive a response. It also may be desired to change the
listening behavior of this library to use a single listener that looks
up the appropriate Promise resolver in `this._openRequests` instead of
the current behavior -- subscribing a new listener for every message.
@satanch
Copy link
Owner

satanch commented Feb 4, 2024

This PR is pretty outdated. Let's coma back to this issue when server changes would be applied.

@satanch satanch closed this Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants