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
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
close ¶
Close all network connections and clear cached proxy state.
Mirrors BlueSky's own close(): shuts the network client's sockets
(the ZMQ context is left to the client), resets connection monitoring,
and clears tracked nodes/servers, data caches, emission timestamps,
and the pending command dictionary.
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
reconnect ¶
Reconnect to the BlueSky server with fresh ZMQ resources.
Stops the current client, clears state, then starts a new connection
via start_client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hostname
|
str | None
|
BlueSky server hostname/IP to reconnect to. When None, the previously configured host is reused. |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated from |
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
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 |