armature-websocket 0.2.0

WebSocket server and client support for Armature using tokio-tungstenite
Documentation

Armature WebSocket

WebSocket server and client support for the Armature framework using tokio-tungstenite.

Features

  • WebSocket server with connection management
  • WebSocket client for outbound connections
  • Room-based message broadcasting
  • Connection state management
  • Heartbeat/ping-pong support
  • JSON message serialization

Example

use armature_websocket::{WebSocketServer, WebSocketHandler, Message};
use async_trait::async_trait;

struct ChatHandler;

#[async_trait]
impl WebSocketHandler for ChatHandler {
    async fn on_connect(&self, connection_id: &str) {
        println!("Client connected: {}", connection_id);
    }

    async fn on_message(&self, connection_id: &str, message: Message) {
        println!("Received from {}: {:?}", connection_id, message);
    }

    async fn on_disconnect(&self, connection_id: &str) {
        println!("Client disconnected: {}", connection_id);
    }
}