Whitebox
API
¶
Standarized API of whitebox for plugins to interact with the core system.
Attributes:
Name | Type | Description |
---|---|---|
location |
LocationService instance for interacting with the location service |
|
traffic |
TrafficService instance for interacting with the traffic service |
|
status |
StatusService instance for interacting with the status service |
EventEmitter
¶
emit(event_type, data)
async
¶
Emit an event and invoke its handler and callbacks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_type
|
str
|
The type of event to emit. |
required |
data
|
any
|
The data to pass to the event handler and callbacks. |
required |
Returns:
Type | Description |
---|---|
dict
|
A context dictionary containing the result of the event handler. |
Raises:
Type | Description |
---|---|
EventNotFoundException
|
If no event is registered for the given type. |
EventHandlerException
|
If there is an error invoking the event handler. |
Event
¶
EventRegistry
¶
Bases: RegistryBase
Registry for managing events and their handlers. Allows registering event handlers and callbacks.
register_callback(event_type, callback)
¶
Register a callback for an existing event.
register_event(event_type, handler, callbacks=None)
¶
Register an event with its handler and optional callbacks.
unregister_callback(event_type, callback)
¶
Unregister a callback for an existing event.
unregister_event(event_type)
¶
Unregister an event by its type.
BaseWebsocketConsumer
¶
Bases: AsyncWebsocketConsumer
This consumer handles WebSocket connections for whitebox.
connect()
async
¶
Called when client connects to the WebSocket.
disconnect(close_code)
async
¶
Called when client disconnects from the WebSocket.
on_connect()
async
¶
Called when the WebSocket connection is established. This method can be overridden to handle additional logic on connect.
receive(text_data)
async
¶
Called when client sends a message to the WebSocket.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text_data
|
str
|
The message sent by the client. |
required |
FlightConsumer
¶
Bases: BaseWebsocketConsumer