Call Kicking and Timeouting, basics of anonymous calls
This commit is contained in:
parent
494e08241c
commit
309342b730
5 changed files with 159 additions and 22 deletions
|
|
@ -1,3 +1,9 @@
|
|||
use std::{
|
||||
sync::Arc,
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use tokio::sync::RwLock;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::calls::call_util;
|
||||
|
|
@ -6,6 +12,7 @@ pub struct Caller {
|
|||
pub user_id: i64,
|
||||
pub call_id: Uuid,
|
||||
pub has_admin: bool,
|
||||
pub timeout: RwLock<i64>,
|
||||
}
|
||||
|
||||
impl Caller {
|
||||
|
|
@ -14,6 +21,7 @@ impl Caller {
|
|||
user_id,
|
||||
call_id,
|
||||
has_admin,
|
||||
timeout: RwLock::new(0),
|
||||
}
|
||||
}
|
||||
pub fn set_admin(&mut self, has_admin: bool) {
|
||||
|
|
@ -22,6 +30,16 @@ impl Caller {
|
|||
pub fn has_admin(&self) -> bool {
|
||||
self.has_admin
|
||||
}
|
||||
pub async fn is_timeout(&self) -> bool {
|
||||
*self.timeout.read().await
|
||||
> SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis() as i64
|
||||
}
|
||||
pub async fn set_timeout(&self, timeout: i64) {
|
||||
*self.timeout.write().await = timeout;
|
||||
}
|
||||
pub fn create_token(&self) -> String {
|
||||
if let Ok(token) = call_util::create_token(self.user_id, self.call_id, self.has_admin()) {
|
||||
token
|
||||
|
|
|
|||
Loading…
Reference in a new issue