Proxy Managers¶
Each manager owns one concern of the proxy: connection lifecycle, node and server tracking, command processing, and data emission.
WebATM.proxy.managers.connection_manager¶
WebATM.proxy.managers.connection_manager ¶
Connection management for the BlueSky proxy.
ConnectionManager ¶
Manage the BlueSky client connection lifecycle.
Owns creation and teardown of the network client, the 20 ms network update timer, data-flow timeout detection, and disconnection cleanup, following the ZMQ create-on-connect / destroy-on-close pattern.
Initialize the connection manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proxy
|
BlueSkyProxy
|
Parent proxy instance. |
required |
Source code in WebATM/proxy/managers/connection_manager.py
start_client ¶
Start the network client with fresh state, following the ZMQ pattern.
Stops any existing connection first, creates the BlueSky network client if needed, wires its node/server signals to the node manager, connects to the server, and starts the network update and backup emission timers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hostname
|
str | None
|
BlueSky server hostname/IP. When None, the
proxy's currently configured |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the connection to the BlueSky server fails. |
Exception
|
If the network client cannot be created. |
Source code in WebATM/proxy/managers/connection_manager.py
mark_connected ¶
Flip the proxy to connected once the first node is detected.
Restarts the data-flow timeout clock from "first node appeared" — no
data can arrive before nodes exist, so a slow cold start must not
count against connection_timeout. Called from both the node-added
signal and the network timer (whichever sees the first node first);
a no-op when already connected.
Source code in WebATM/proxy/managers/connection_manager.py
close ¶
Close the network client's sockets and clear cached proxy state.
The client instance itself is kept (only stop_client destroys it);
the app reconnects by creating a fresh BlueSkyProxy, so this only
has to release the sockets and forget the cached server state.
Source code in WebATM/proxy/managers/connection_manager.py
stop_client ¶
Stop the client with full cleanup and proper ZMQ error handling.
Cancels the network/backup timers, closes and destroys the network client, and clears remaining proxy state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
str
|
Cleanup context — |
'disconnect'
|
Source code in WebATM/proxy/managers/connection_manager.py
WebATM.proxy.managers.node_manager¶
WebATM.proxy.managers.node_manager ¶
Node and server management for the BlueSky proxy.
NodeManager ¶
Track BlueSky simulation nodes and servers.
Reacts to node/server discovery and removal callbacks from the network
client, keeps the proxy's tracked_nodes/tracked_servers maps in
sync, detects server shutdown when all nodes disappear, and emits
node_info updates to connected web clients.
Initialize the node manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proxy
|
BlueSkyProxy
|
Parent proxy instance. |
required |
Source code in WebATM/proxy/managers/node_manager.py
serialize_node_info ¶
Build the JSON-serializable node_info payload.
Decodes the binary node/server IDs kept in tracked_nodes and
tracked_servers into the string forms the frontend expects
(NodeData in frontend/src/data/types.ts). Used for both the
node_info Socket.IO event and the initial_data snapshot.
Returns:
| Type | Description |
|---|---|
dict
|
|
Source code in WebATM/proxy/managers/node_manager.py
actnode ¶
Select the active simulation node via the network client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id
|
bytes
|
ID of the node to make active. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The result of |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the network client is not initialized. |
Source code in WebATM/proxy/managers/node_manager.py
addnodes ¶
Request new simulation nodes from a BlueSky server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Number of nodes to add. |
required |
server_id
|
bytes | None
|
Server to add the nodes on. When None, the network client picks its default server. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The result of |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the network client is not initialized. |
Source code in WebATM/proxy/managers/node_manager.py
delnode ¶
Request termination of a single simulation node via DELNODE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id
|
bytes
|
ID of the node to terminate. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The result of |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the network client is not initialized. |
Source code in WebATM/proxy/managers/node_manager.py
WebATM.proxy.managers.command_processor¶
WebATM.proxy.managers.command_processor ¶
Command processing and forwarding for the BlueSky proxy.
CommandProcessor ¶
Handle command processing, forwarding, and echo responses.
Queues user/GUI commands on the network client's stack, forwards them to the BlueSky server (answering bare HELP/? locally), and emits echo responses back to connected web clients.
Initialize the command processor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proxy
|
BlueSkyProxy
|
Parent proxy instance. |
required |
Source code in WebATM/proxy/managers/command_processor.py
send_command ¶
Send a command to the simulation using stack processing.
Queues the command on the client stack and immediately processes the queue, forwarding to the BlueSky server as appropriate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
The stack command line to send (e.g. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the command was queued and processed, False if the BlueSky client is not running or an error occurred. |
Source code in WebATM/proxy/managers/command_processor.py
forward ¶
Forward one or more stack commands to the BlueSky server.
Mirrors BlueSky's stack.forward(): sends to the given target, the
active node, or the server. Multiple commands may be passed as
separate arguments and/or semicolon-separated within a single string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*cmdlines
|
str
|
One or more stack command lines to forward. |
()
|
target_id
|
bytes | None
|
Explicit node/server ID to address. When None, falls back to the active node, then the server. |
None
|
Source code in WebATM/proxy/managers/command_processor.py
WebATM.proxy.managers.data_manager¶
WebATM.proxy.managers.data_manager ¶
Data emission and state management for the BlueSky proxy.
DataManager ¶
Manage Socket.IO data emission, backup timers, and state clearing.
Emits connection status, cleared-state payloads and periodic backup data to connected web clients, and provides the initial-page-load snapshot of the proxy's cached simulation state.
Initialize the data manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proxy
|
BlueSkyProxy
|
Parent proxy instance. |
required |
Source code in WebATM/proxy/managers/data_manager.py
start_backup_timer ¶
Start (or restart) the 0.5 s backup emission timer.
Source code in WebATM/proxy/managers/data_manager.py
backup_data_emit ¶
Re-emit cached sim/traffic data and reschedule the backup timer.
Safety net for web clients that connect between subscriber emissions:
pushes the latest cached siminfo and acdata payloads, then
schedules the next backup tick while the proxy is running.
Source code in WebATM/proxy/managers/data_manager.py
get_current_data ¶
Build the simulation state snapshot for an initial page load.
Shapes (polygons/polylines) are only included for the currently active node.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Snapshot with |