Proxy Core¶
The proxy gateway bridging the web interface with the BlueSky network
client. BlueSkyProxy is a thin delegation layer composed of the
managers; the handlers are
registered against BlueSky topics by subscribers.
WebATM.proxy¶
WebATM.proxy ¶
BlueSky proxy package for web interface communication.
This package provides the BlueSky proxy gateway that bridges the web interface with the BlueSky network client. It includes:
- Core proxy class for client management
- Event handlers for simulation data
- Subscriber registration for network events
BlueSkyProxy ¶
Bridge between the web interface and the BlueSky network client.
Owns the network client lifecycle, caches incoming simulation data, and relays it to connected web clients over Socket.IO. The actual work is delegated to four focused managers following a composition pattern.
Attributes:
| Name | Type | Description |
|---|---|---|
bluesky_client |
BlueSkyClient | None
|
Active network client; created when connecting and destroyed on close. |
running |
bool
|
Whether the network update loop is active. |
socketio |
Flask-SocketIO instance used to emit events to web clients. |
|
traffic_data |
dict
|
Latest ACDATA payload, cached for new clients. |
sim_data |
dict
|
Latest SIMINFO payload, cached for new clients. |
echo_data |
dict
|
Latest echo message, cached for new clients. |
tracked_nodes |
dict
|
Known simulation nodes keyed by hex node ID. |
tracked_servers |
dict
|
Known servers keyed by raw server ID. |
cmddict |
dict
|
Command dictionary mapping command names to their comma-separated argument signatures (seeded locally, replaced by BlueSky's STACKCMDS broadcast). |
connection_mgr |
ConnectionManager
|
Connection lifecycle manager. |
node_mgr |
NodeManager
|
Node/server tracking manager. |
command_proc |
CommandProcessor
|
Command processing manager. |
data_mgr |
DataManager
|
Data emission and state manager. |
Initialize the proxy with empty caches and its manager modules.
Source code in WebATM/proxy/core.py
is_connected
property
¶
Single source of truth for "are we connected to BlueSky".
True once the client is running, has previously detected at least one node, and still has active nodes. Every consumer (Socket.IO payloads, REST routes) should read this instead of re-deriving the formula.
Returns:
| Type | Description |
|---|---|
bool
|
True when connected to a BlueSky server with active nodes. |
start_client ¶
Start the network client with fresh state, following the ZMQ pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hostname
|
str
|
BlueSky server hostname or IP address. Defaults to the previously configured server address. |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the connection to the BlueSky server fails. |
Source code in WebATM/proxy/core.py
stop_client ¶
Stop the client with improved cleanup and proper ZMQ error handling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
str
|
Reason for stopping — "disconnect" for reconnection, "manual" for user disconnect, or "shutdown" for app termination. |
'disconnect'
|
Source code in WebATM/proxy/core.py
reconnect ¶
close ¶
actnode ¶
addnodes ¶
delnode ¶
send_command ¶
forward ¶
start_backup_timer ¶
backup_data_emit ¶
register_subscribers ¶
Register all handler callbacks with the proxy's BlueSky client.
Iterates over SUBSCRIPTIONS and subscribes each (topic, callback,
actonly) triple on the global proxy's network client. Topics flagged
actonly only deliver data for the active node and are re-subscribed
when the active node changes.
Logs an error and returns early if no global proxy is set, or a warning if the proxy has no connected BlueSky client yet.
Source code in WebATM/proxy/subscribers.py
get_bluesky_proxy ¶
Get the current BlueSky proxy instance.
Returns:
| Type | Description |
|---|---|
BlueSkyProxy | None
|
The globally registered proxy instance, or None if no proxy has been set yet. |
set_bluesky_proxy ¶
Set the global BlueSky proxy instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proxy
|
BlueSkyProxy | None
|
Proxy instance to register globally, or None to clear the current one. |
required |
WebATM.proxy.core¶
WebATM.proxy.core ¶
BlueSky proxy gateway for web interface communication.
BlueSkyProxy ¶
Bridge between the web interface and the BlueSky network client.
Owns the network client lifecycle, caches incoming simulation data, and relays it to connected web clients over Socket.IO. The actual work is delegated to four focused managers following a composition pattern.
Attributes:
| Name | Type | Description |
|---|---|---|
bluesky_client |
BlueSkyClient | None
|
Active network client; created when connecting and destroyed on close. |
running |
bool
|
Whether the network update loop is active. |
socketio |
Flask-SocketIO instance used to emit events to web clients. |
|
traffic_data |
dict
|
Latest ACDATA payload, cached for new clients. |
sim_data |
dict
|
Latest SIMINFO payload, cached for new clients. |
echo_data |
dict
|
Latest echo message, cached for new clients. |
tracked_nodes |
dict
|
Known simulation nodes keyed by hex node ID. |
tracked_servers |
dict
|
Known servers keyed by raw server ID. |
cmddict |
dict
|
Command dictionary mapping command names to their comma-separated argument signatures (seeded locally, replaced by BlueSky's STACKCMDS broadcast). |
connection_mgr |
ConnectionManager
|
Connection lifecycle manager. |
node_mgr |
NodeManager
|
Node/server tracking manager. |
command_proc |
CommandProcessor
|
Command processing manager. |
data_mgr |
DataManager
|
Data emission and state manager. |
Initialize the proxy with empty caches and its manager modules.
Source code in WebATM/proxy/core.py
is_connected
property
¶
Single source of truth for "are we connected to BlueSky".
True once the client is running, has previously detected at least one node, and still has active nodes. Every consumer (Socket.IO payloads, REST routes) should read this instead of re-deriving the formula.
Returns:
| Type | Description |
|---|---|
bool
|
True when connected to a BlueSky server with active nodes. |
start_client ¶
Start the network client with fresh state, following the ZMQ pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hostname
|
str
|
BlueSky server hostname or IP address. Defaults to the previously configured server address. |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the connection to the BlueSky server fails. |
Source code in WebATM/proxy/core.py
stop_client ¶
Stop the client with improved cleanup and proper ZMQ error handling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
str
|
Reason for stopping — "disconnect" for reconnection, "manual" for user disconnect, or "shutdown" for app termination. |
'disconnect'
|
Source code in WebATM/proxy/core.py
reconnect ¶
close ¶
actnode ¶
addnodes ¶
delnode ¶
send_command ¶
forward ¶
start_backup_timer ¶
backup_data_emit ¶
WebATM.proxy.subscribers¶
WebATM.proxy.subscribers ¶
Subscriber registration for BlueSky network events.
Maps BlueSky data topics (SIMINFO, ACDATA, ECHO, ...) to the handler
functions in :mod:WebATM.proxy.handlers and registers them with the
active BlueSky network client.
register_subscribers ¶
Register all handler callbacks with the proxy's BlueSky client.
Iterates over SUBSCRIPTIONS and subscribes each (topic, callback,
actonly) triple on the global proxy's network client. Topics flagged
actonly only deliver data for the active node and are re-subscribed
when the active node changes.
Logs an error and returns early if no global proxy is set, or a warning if the proxy has no connected BlueSky client yet.