1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! 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 [`Incoming`] and [`Outgoing`] message enums
//! - **Registry**: Store slots and methods with [`Registry`]
//! - **Server**: Full WebSocket server with [`AroraWSServer`] (requires `server` feature)
//! - **Connection Trait**: Implements [`AroraConnection`] for protocol-agnostic usage
//!
//! # Protocol Overview
//!
//! Messages are JSON-encoded with a `type` field discriminator:
//!
//! ```json
//! // 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
//!
//! ```rust,no_run
//! 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();
//! }
//! ```
/// The WS server as an Arora `Bridge`.
pub use ;
pub use ;
pub use ;
pub use Registry;
pub use ;
pub use SlotInfo;
pub use CancellationToken;
pub use ;
pub use ;