fix: add automatic 1 Hz keepalive heartbeat for stealth Python clients#361
Merged
fix: add automatic 1 Hz keepalive heartbeat for stealth Python clients#361
Conversation
The Python stealth client was disconnecting because no periodic signal was sent to keep the server's 5-second CLIENT_TIMEOUT from expiring. Mirrors Unity's TransformSyncManager architecture: - Add STEALTH_HEARTBEAT_INTERVAL = 1.0 (matches HEARTBEAT_INTERVAL_SECONDS) - send_stealth_handshake() now sets _is_stealth_mode = True and starts the internal heartbeat via _send_stealth_heartbeat() - _maybe_send_stealth_heartbeat() is called each _receive_loop iteration; it re-enqueues a stealth packet whenever the interval elapses - No caller change needed: one send_stealth_handshake() call is enough Also adds test_stealth_heartbeat.py with 11 tests covering the unit-level timer logic and an integration test that verifies the client stays registered past the server timeout with a short CLIENT_TIMEOUT config. Closes #356 Co-authored-by: Masahiro Yamaguchi <from2001@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an automatic keepalive heartbeat for Python “stealth” clients so they remain connected past the server’s CLIENT_TIMEOUT, aligning Python behavior with Unity’s periodic stealth signaling.
Changes:
- Introduces
STEALTH_HEARTBEAT_INTERVAL = 1.0and stealth-mode state/timer tracking in the Python client. - Makes
send_stealth_handshake()enable stealth mode and trigger periodic heartbeats from the receive loop. - Adds unit + integration tests validating the 1 Hz heartbeat and that the client remains registered beyond a shortened server timeout.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
STYLY-NetSync-Server/src/styly_netsync/client.py |
Adds stealth heartbeat interval constant, stealth state, and periodic heartbeat emission in _receive_loop. |
STYLY-NetSync-Server/tests/test_stealth_heartbeat.py |
New tests for stealth heartbeat behavior (unit + end-to-end server/client). |
STYLY-NetSync-Server/src/styly_netsync/client_simulator.py |
Formatting-only change to battery drain constant expression. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
|
LGTM |
mhama
approved these changes
Mar 10, 2026
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.
The Python stealth client was disconnecting because no periodic signal was sent to keep the server's 5-second CLIENT_TIMEOUT from expiring.
Mirrors Unity's TransformSyncManager architecture:
Closes #356
Generated with Claude Code