This commit is contained in:
azw 2023-11-13 13:21:29 +00:00
parent 69f8764c4a
commit 89c2cb73ff
2 changed files with 22 additions and 1 deletions

View File

@ -1,3 +1,4 @@
use std::time::{Duration, Instant};
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
use std::cell::RefCell; use std::cell::RefCell;
use r9_macro::SharedFromSelf; use r9_macro::SharedFromSelf;
@ -18,6 +19,26 @@ use actix_web::{
Error, Error,
Responder}; Responder};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use actix::prelude::*;
#[derive(Debug)]
pub struct WsSession {
/// unique session id
pub id: usize,
/// Client must send ping at least once per 10 seconds (CLIENT_TIMEOUT),
/// otherwise we drop connection.
pub hb: Instant,
/// joined room
pub room: String,
/// peer name
pub name: Option<String>,
// server
pub addr: Addr<WsConn>,
}
#[derive(SharedFromSelf)] #[derive(SharedFromSelf)]
#[derive(Singleton)] #[derive(Singleton)]
@ -26,7 +47,7 @@ pub struct WsListener {
} }
/// Define HTTP actor /// Define HTTP actor
struct WsConn; pub struct WsConn;
impl Actor for WsConn { impl Actor for WsConn {
type Context = ws::WebsocketContext<Self>; type Context = ws::WebsocketContext<Self>;

View File