use crate::common::error::Result;
use crate::common::protocol::Frame;
use async_trait::async_trait;
#[async_trait]
pub trait ConnectionHandler: Send + Sync {
async fn handle_frame(&self, frame: &Frame, connection_id: &str) -> Result<Option<Frame>>;
async fn on_connect(&self, connection_id: &str) -> Result<()> {
let _ = connection_id;
Ok(())
}
async fn on_disconnect(&self, connection_id: &str) -> Result<()> {
let _ = connection_id;
Ok(())
}
}
#[async_trait]
pub trait Server: Send + Sync {
async fn start(&mut self) -> Result<()>;
async fn stop(&mut self) -> Result<()>;
fn is_running(&self) -> bool;
}
mod common;
#[cfg(any(feature = "websocket", feature = "quic", feature = "tcp"))]
pub mod hybrid;
#[cfg(feature = "quic")]
pub mod quic;
pub mod server_core;
#[cfg(feature = "tcp")]
pub mod tcp;
#[cfg(feature = "websocket")]
pub mod websocket;
#[cfg(any(feature = "websocket", feature = "quic", feature = "tcp"))]
pub use hybrid::HybridServer;
#[cfg(feature = "quic")]
pub use quic::QUICServer;
#[cfg(feature = "tcp")]
pub use tcp::TCPServer;
#[cfg(feature = "websocket")]
pub use websocket::WebSocketServer;