Repository navigation
fix(devices): emit 'disconnect' when a device goes away, and let it reconnect - #13
Draft
joethesaint wants to merge 1 commit into
Draft
joethesaint wants to merge 1 commit into
joethesaint wants to merge 1 commit into
Conversation
…econnect A player that is switched off, rebooted or unplugged closes its main connection, but nothing noticed: StageLinqDevices had no device-level disconnect event, and the device stayed CONNECTED in discoveryStatus, so its next announcement (after a reboot) was ignored. NetworkDevice now calls an onConnectionLost handler when the device closes the main connection (not when we disconnect: disconnect() clears the connection before the socket's close event). StageLinqDevices registers it, forgets the device (discoveryStatus, devices, pending StateMap setup) and emits 'disconnect' with its ConnectionInfo. Tests: a remote close calls the handler and our own disconnect() doesn't; StageLinqDevices emits 'disconnect' and no longer counts the device as connected or connecting.
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.
A player that is switched off, rebooted or unplugged closes its main connection, but nothing notices it:
StageLinqDeviceshas no device-level disconnect event, and the device stays CONNECTED indiscoveryStatus, so its next announcement (after a reboot) is ignored.NetworkDevicenow calls anonConnectionLosthandler when the device closes the main connection, not when we disconnect (disconnect()clears the connection before the socket's close event fires).StageLinqDevicesregisters it, forgets the device (discoveryStatus,devices, any pending StateMap setup) and emits'disconnect'with itsConnectionInfo(added to the typed events).Tests: a remote close calls the handler and our own
disconnect()doesn't;StageLinqDevicesemits'disconnect'and no longer counts the device as connected or connecting. The two test fakes ofNetworkDevicegainonConnectionLost. The three new tests fail on the old source and pass with the change;tsc --noEmitis clean. The full suite has three failures that are also on a cleanmainhere (getTempFilePathcompares Windows paths with/tmp/localdb), so they are not from this change.