Skip to content

fix(devices): emit 'disconnect' when a device goes away, and let it reconnect - #13

Draft
joethesaint wants to merge 1 commit into
chrisle:mainfrom
joethesaint:fix/device-disconnect-event
Draft

joethesaint wants to merge 1 commit into
chrisle:mainfrom
joethesaint:fix/device-disconnect-event

Conversation

@joethesaint

Copy link
Copy Markdown

A player that is switched off, rebooted or unplugged closes its main connection, but nothing notices it: StageLinqDevices has no device-level disconnect event, and the device stays CONNECTED in discoveryStatus, so its next announcement (after a reboot) is 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 fires). StageLinqDevices registers it, forgets the device (discoveryStatus, devices, any pending StateMap setup) and emits 'disconnect' with its ConnectionInfo (added to the typed events).

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. The two test fakes of NetworkDevice gain onConnectionLost. The three new tests fail on the old source and pass with the change; tsc --noEmit is clean. The full suite has three failures that are also on a clean main here (getTempFilePath compares Windows paths with /tmp/localdb), so they are not from this change.

…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.
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.

1 participant