-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Python net_sync_manager: Server IP discovered via discovery is not automatically used for sync connection
Summary
In the Python client (net_sync_manager), the server address and port information discovered via UDP server discovery is not automatically passed to the sync connection process. Discovery and connection are completely decoupled, and the integrated "discover → connect" flow that exists on the Unity side is missing.
Current Behavior
In client.py, the _discovery_loop (L1098-1147) only fires the on_server_discovered event when a server is found, with no bridging to the connection process.
A comment at L1131 reads # Could auto-reconnect here if desired, indicating this was intentionally left unimplemented.
Specifically, the following are missing:
- Discovered address/ports are not reflected in internal state —
self._server,self._dealer_port,self._sub_portremain at the values set in__init__and are never updated start()is not automatically called after discovery — Thestart()method (L271) connects using the internal address/ports, but is never invoked from the discovery flow- Discovery does not auto-stop after finding a server — Even after a server is found,
stop_discovery()is not called, and broadcasts continue every 5 seconds - No way to apply discovered address to an existing instance — No setter or method exists to update the address/ports, so users must create a new instance entirely
Comparison with Unity (C#)
On the Unity side, the flow from discovery to connection is fully integrated:
| Step | Unity (C#) | Python |
|---|---|---|
| Server found | OnServerDiscovered event fired | on_server_discovered event fired |
| Store address | Updates _serverAddress, _dealerPort, _subPort | Does nothing |
| Stop discovery | Auto-calls StopDiscovery() | Does not stop |
| Start connection | Auto-calls ConnectionManager.Connect() | Does not connect |
Expected Behavior
When a server is found via discovery, the following flow should execute automatically:
- Reflect the discovered address and ports in internal state
- Stop discovery
- Automatically start the sync connection
Relevant Code
STYLY-NetSync-Server/src/styly_netsync/client.py_discovery_loop(L1098-1147): Discovery loopstart()(L271-318): Connection processon_server_discovered(L201): Event handler (fire only)