mod adapter;
mod error;
mod extract;
mod interceptor;
use std::any::{Any, TypeId};
use std::pin::Pin;
use std::sync::Arc;
use sword_core::State;
pub use adapter::*;
pub use error::*;
pub use extract::*;
pub use interceptor::*;
#[derive(Clone, Debug)]
pub enum SocketEventKind {
Connection,
Disconnection,
Message(&'static str),
Fallback,
}
type SocketCallFn = fn(
Arc<dyn Any + Send + Sync>,
SocketContext,
) -> Pin<Box<dyn Future<Output = ()> + Send>>;
#[derive(Clone)]
pub struct HandlerRegistrar {
pub adapter_type_id: TypeId,
pub namespace: &'static str,
pub event_kind: SocketEventKind,
pub method_name: &'static str,
pub register_fn: fn(Arc<dyn Any + Send + Sync>, SocketRef),
pub call_fn: SocketCallFn,
}
pub struct SocketIoHandlerRegistrar {
pub handler_type_id: TypeId,
pub handler_type_name: &'static str,
pub setup_fn: fn(&State),
}
inventory::collect!(HandlerRegistrar);
inventory::collect!(SocketIoHandlerRegistrar);