Module channel

Module channel 

Source
Expand description

Channel abstraction system for WebSocket messaging

This module provides channel-based messaging capabilities, allowing connections to join/leave channels and enabling targeted message broadcasting to channel members.

§Architecture

The channel system is organized into several logical modules:

  • types - Core types and data structures
  • channel - Individual channel implementation
  • manager - Channel lifecycle and management
  • message - Channel message types
  • events - Event system for channel operations

§Quick Start

use elif_http::websocket::{ChannelManager, ChannelType, ConnectionId};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let manager = ChannelManager::new();
    let creator_id = ConnectionId::new();
    let joiner_id = ConnectionId::new();
     
    // Create a public channel
    let channel_id = manager.create_channel(
        "general".to_string(),
        ChannelType::Public,
        Some(creator_id),
    ).await?;
     
    // Join the channel with a different connection
    manager.join_channel(
        channel_id,
        joiner_id,
        None, // No password needed for public channels
        Some("Alice".to_string()),
    ).await?;
     
    Ok(())
}

Re-exports§

pub use channel::Channel;
pub use events::ChannelEvent;
pub use manager::ChannelManager;
pub use message::ChannelMessage;
pub use types::ChannelId;
pub use types::ChannelManagerStats;
pub use types::ChannelMember;
pub use types::ChannelMetadata;
pub use types::ChannelPermissions;
pub use types::ChannelStats;
pub use types::ChannelType;

Modules§

channel
Core Channel implementation
events
Channel event system
manager
Channel manager for WebSocket channel operations
message
Channel message types and functionality
password
Secure password hashing for channel authentication
types
Core types for the WebSocket channel system