Expand description
Arora WebSocket Protocol
The open local bridge for Arora: a WebSocket server implementing
arora_bridge::Bridge (see bridge::WsBridge), with type-safe message
definitions, a method registry, and a ready-to-use server.
§Features
- Message Types: Type-safe
IncomingandOutgoingmessage enums - Registry: Store slots and methods with
Registry - Server: Full WebSocket server with
AroraWSServer(requiresserverfeature) - Connection Trait: Implements [
AroraConnection] for protocol-agnostic usage
§Protocol Overview
Messages are JSON-encoded with a type field discriminator:
// Client -> Server
{"type": "set_slot_values", "values": {"face/mouth": {"f64": 0.5}}}
{"type": "list_slots", "path": "face"}
{"type": "list_methods"}
{"type": "invoke", "method": "reset", "request_id": "req-1"}
// Server -> Client
{"type": "set_slot_values_resp", "success": true}
{"type": "list_slots_resp", "slots": [...]}
{"type": "list_methods_resp", "methods": [...]}
{"type": "invoke_resp", "success": true, "request_id": "req-1"}§Server Example
use arora_websocket::{AroraWSServer, ServerConfig, MethodInfo, InvokeResult};
use tokio_util::sync::CancellationToken;
#[tokio::main]
async fn main() {
let server = AroraWSServer::with_port(9000);
// Register a method
server.registry().register_method_fn(
MethodInfo {
path: "reset".to_string(),
params: vec![],
return_type: None,
description: Some("Reset to defaults".to_string()),
},
|_args| InvokeResult::ok(),
).await;
// Set update handler
server.set_set_slot_values_handler(|values| {
println!("Received {} updates", values.len());
Ok(())
}).await;
// Run the server
let cancel = CancellationToken::new();
server.run(cancel).await.unwrap();
}Re-exports§
pub use handlers::GetSlotValuesHandler;pub use handlers::MethodHandler;pub use handlers::OnClientConnectedHandler;pub use handlers::SetSlotValuesResult;
Modules§
- bridge
- The WS server as an Arora
Bridge. [WsBridge]: the Vizij WebSocket server driven as an AroraBridge(Phase 5C). - handlers
- Callback types the server dispatches incoming protocol messages to.
Structs§
- AroraWS
Server - WebSocket server for the arora protocol.
- Cancellation
Token - A token which can be used to signal a cancellation request to one or more tasks.
- Invoke
Result - Result type for method invocation.
- KeyValue
- A collection of named
KeyValueFields identified by a UUID. - KeyValue
Field - Method
Info - Metadata describing an available RPC method.
- Method
Param - Descriptor for an RPC method parameter.
- Registry
- Registry for slots and methods.
- Server
Config - Configuration for the WebSocket server.
- Slot
Info - Metadata describing an available slot in the system.
Enums§
- Incoming
- Messages received from WebSocket clients.
- Outgoing
- Messages sent to WebSocket clients.
- Type
- Value
Functions§
- process_
message - Process an incoming message and return the response.
Type Aliases§
- SetSlot
Values Handler - Callback for handling SetSlotValues messages.