Migrate to TCP-only streaming and add diagnostics
This commit is contained in:
parent
68e8c67daa
commit
fe08e595e9
5 changed files with 116 additions and 188 deletions
26
src/state.rs
26
src/state.rs
|
|
@ -1,41 +1,45 @@
|
|||
use dashmap::DashMap;
|
||||
use shared::{ControlMsg, UserId};
|
||||
use std::net::SocketAddr;
|
||||
use shared::UserId;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::broadcast;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AppState {
|
||||
pub rooms: Arc<DashMap<String, Room>>,
|
||||
pub peers_by_addr: Arc<DashMap<SocketAddr, PeerLocation>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PeerLocation {
|
||||
pub room_id: String,
|
||||
pub user_id: UserId,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Room {
|
||||
pub id: String,
|
||||
pub peers: DashMap<UserId, Peer>,
|
||||
// Channel for broadcasting control messages within the room
|
||||
pub tx: broadcast::Sender<ControlMsg>,
|
||||
pub tx: broadcast::Sender<RoomMessage>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RoomMessage {
|
||||
pub from_user_id: UserId,
|
||||
pub content: RoomMessageContent,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum RoomMessageContent {
|
||||
Control(shared::ControlMsg),
|
||||
Media(Vec<u8>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Peer {
|
||||
pub id: UserId,
|
||||
pub display_name: String,
|
||||
pub addr: Option<SocketAddr>, // UDP address
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
rooms: Arc::new(DashMap::new()),
|
||||
peers_by_addr: Arc::new(DashMap::new()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue