simple websocket implementation (without auth use)
This commit is contained in:
@@ -2,13 +2,25 @@ use std::sync::Arc;
|
||||
use dashmap::DashMap;
|
||||
use r2d2::{Pool};
|
||||
use r2d2_sqlite::SqliteConnectionManager;
|
||||
use tokio::sync::mpsc;
|
||||
use axum::extract::{ws::{Message, WebSocket, WebSocketUpgrade}, State};
|
||||
|
||||
type HotelId = i32; // or i32 if you want numeric ids
|
||||
|
||||
/// Type alias: user_id → sender to that user
|
||||
type UserMap = DashMap<i32, mpsc::UnboundedSender<Message>>;
|
||||
/// hotel_id → users
|
||||
type HotelMap = DashMap<i32, Arc<UserMap>>;
|
||||
/// global map of all hotels
|
||||
type WsMap = Arc<HotelMap>;
|
||||
/// Type alias: user_id → sender to that user
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
pub hotel_pools: HotelPool,
|
||||
pub logs_pool: Pool<SqliteConnectionManager>,
|
||||
pub ws_map: WsMap,
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user