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; only
the methods that routes, Socket.IO handlers, network-event handlers or
tests actually call through the proxy are re-exposed here — manager
internals are reached via connection_mgr/node_mgr/
command_proc/data_mgr directly.
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. |
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 the active node's STACKCMDS answer). |
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
close ¶
actnode ¶
addnodes ¶
delnode ¶
send_command ¶
forward ¶
register_subscribers ¶
Register all handler callbacks with the proxy's BlueSky client.
Iterates over SUBSCRIPTIONS and subscribes each (topic, callback,
actonly) triple on the 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 proxy is available, or a warning if the proxy has no connected BlueSky client yet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proxy
|
BlueSkyProxy | None
|
Proxy whose client to attach to. Defaults to the globally registered proxy. Callers that just connected a specific proxy instance should pass it explicitly, so a concurrent reconnect swapping the global can never leave the client they started without subscribers. |
None
|
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; only
the methods that routes, Socket.IO handlers, network-event handlers or
tests actually call through the proxy are re-exposed here — manager
internals are reached via connection_mgr/node_mgr/
command_proc/data_mgr directly.
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. |
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 the active node's STACKCMDS answer). |
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
close ¶
actnode ¶
addnodes ¶
delnode ¶
send_command ¶
forward ¶
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 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 proxy is available, or a warning if the proxy has no connected BlueSky client yet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proxy
|
BlueSkyProxy | None
|
Proxy whose client to attach to. Defaults to the globally registered proxy. Callers that just connected a specific proxy instance should pass it explicitly, so a concurrent reconnect swapping the global can never leave the client they started without subscribers. |
None
|