armature_websocket/lib.rs
1//! # Armature WebSocket
2//!
3//! WebSocket server and client support for the Armature framework using tokio-tungstenite.
4//!
5//! ## Features
6//!
7//! - WebSocket server with connection management
8//! - WebSocket client for outbound connections
9//! - Room-based message broadcasting
10//! - Connection state management
11//! - Heartbeat/ping-pong support
12//! - JSON message serialization
13//!
14//! ## Example
15//!
16//! ```rust,no_run
17//! use armature_websocket::{WebSocketServer, WebSocketHandler, Message};
18//! use async_trait::async_trait;
19//!
20//! struct ChatHandler;
21//!
22//! #[async_trait]
23//! impl WebSocketHandler for ChatHandler {
24//! async fn on_connect(&self, connection_id: &str) {
25//! println!("Client connected: {}", connection_id);
26//! }
27//!
28//! async fn on_message(&self, connection_id: &str, message: Message) {
29//! println!("Received from {}: {:?}", connection_id, message);
30//! }
31//!
32//! async fn on_disconnect(&self, connection_id: &str) {
33//! println!("Client disconnected: {}", connection_id);
34//! }
35//! }
36//! ```
37
38#![warn(missing_docs)]
39#![warn(rustdoc::missing_crate_level_docs)]
40
41mod client;
42mod connection;
43mod error;
44mod handler;
45mod message;
46mod room;
47mod server;
48
49pub use client::{WebSocketClient, WebSocketClientBuilder};
50pub use connection::{Connection, ConnectionId, ConnectionState};
51pub use error::{WebSocketError, WebSocketResult};
52pub use handler::{LoggingHandler, WebSocketHandler};
53pub use message::{Message, MessageType};
54pub use room::{Room, RoomId, RoomManager};
55pub use server::{WebSocketServer, WebSocketServerBuilder, WebSocketServerConfig};
56
57// Re-export commonly used types from tungstenite
58pub use tungstenite::protocol::CloseFrame;
59pub use tungstenite::Message as RawMessage;
60