Send LAN_LOGOFF on disconnect#11
Merged
Merged
Conversation
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.
Problem
Z21CommandStation.DisconnectAsyncclosed the UDP socket without sendingLAN_LOGOFF, so the Z21 kept the client's slot registered (~60s). Repeated connect/disconnect cycles accumulate stale slots and exhaust the command station's client/subscription table; the reconnected client then stops receivingLAN_X_LOCO_INFObroadcasts (loco-specific per-subscriber forwarding is dropped) while global broadcasts likeLAN_SYSTEMSTATE_DATACHANGEDkeep arriving. Observed on hardware as "loco updates stop after a reconnect, but feedback/system state still work."Change
DisconnectAsyncnow sendsLogOffCommand(LAN_LOGOFF,0x0030) before closing the transport, so the Z21 frees the slot immediately. The send is guarded byIsConnectedand wrapped in try/catch (logged) so the transport is always closed even if the logoff send fails.Tests
DisconnectAsync_SendsLogOffThenDisconnectsDisconnectAsync_WhenNotConnected_DoesNotSendLogOffDisconnectAsync_WhenLogOffSendFails_StillDisconnects(via newFakeTransport.ThrowOnSend)Full Z21.Client suite green (695 tests).