[FIX] Migrated to Tensamin Transport Protocol
This commit is contained in:
parent
d4a1b6922b
commit
c9d21fd3c6
24 changed files with 1451 additions and 2252 deletions
|
|
@ -1,11 +1,11 @@
|
|||
use json::JsonValue;
|
||||
use epsilon_core::{CommunicationType, CommunicationValue, DataTypes, DataValue};
|
||||
|
||||
use std::{env, sync::Arc, time::Duration};
|
||||
use tokio::sync::RwLock;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
calls::{call_util, caller::Caller},
|
||||
data::communication::{CommunicationType, CommunicationValue, DataTypes},
|
||||
omega::omega_connection::get_omega_connection,
|
||||
};
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ impl CallGroup {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn get_caller(&self, user_id: i64) -> Option<Arc<Caller>> {
|
||||
pub async fn get_caller(&self, user_id: u64) -> Option<Arc<Caller>> {
|
||||
self.members
|
||||
.read()
|
||||
.await
|
||||
|
|
@ -62,7 +62,7 @@ impl CallGroup {
|
|||
let response_cv = get_omega_connection()
|
||||
.await_response(
|
||||
&CommunicationValue::new(CommunicationType::shorten_link)
|
||||
.add_data(DataTypes::link, JsonValue::from(long_link)),
|
||||
.add_data(DataTypes::link, DataValue::Str(long_link)),
|
||||
Some(Duration::from_secs(20)),
|
||||
)
|
||||
.await;
|
||||
|
|
@ -70,7 +70,6 @@ impl CallGroup {
|
|||
*self.short_link.write().await = Some(
|
||||
response
|
||||
.get_data(DataTypes::link)
|
||||
.unwrap()
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
|
|
@ -84,7 +83,7 @@ impl CallGroup {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn create_anonymous_token(&self, user_id: i64) -> Option<String> {
|
||||
pub async fn create_anonymous_token(&self, user_id: u64) -> Option<String> {
|
||||
if self.is_anonymous().await {
|
||||
if let Ok(token) = call_util::create_token(user_id, self.call_id, false) {
|
||||
return Some(token);
|
||||
|
|
@ -93,7 +92,7 @@ impl CallGroup {
|
|||
None
|
||||
}
|
||||
|
||||
pub async fn remove_caller(&self, user_id: i64) {
|
||||
pub async fn remove_caller(&self, user_id: u64) {
|
||||
let _ = call_util::remove_participant(self.call_id, user_id).await;
|
||||
self.members
|
||||
.write()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use crate::calls::{call_group::CallGroup, caller::Caller};
|
|||
|
||||
pub static CALL_GROUPS: Lazy<DashMap<Uuid, Arc<CallGroup>>> = Lazy::new(|| DashMap::new());
|
||||
|
||||
pub async fn get_call_invites(user_id: i64) -> Vec<Arc<Caller>> {
|
||||
pub async fn get_call_invites(user_id: u64) -> Vec<Arc<Caller>> {
|
||||
let mut callers = Vec::new();
|
||||
for (_, cg) in CALL_GROUPS.clone().into_iter() {
|
||||
let members = cg.members.read().await;
|
||||
|
|
@ -28,7 +28,7 @@ pub async fn get_call(call_id: Uuid) -> Option<Arc<CallGroup>> {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn get_call_groups(user_id: i64) -> Vec<Arc<CallGroup>> {
|
||||
pub async fn get_call_groups(user_id: u64) -> Vec<Arc<CallGroup>> {
|
||||
let mut call_groups = Vec::new();
|
||||
for (_, cg) in CALL_GROUPS.clone().into_iter() {
|
||||
let is_member = {
|
||||
|
|
@ -43,7 +43,7 @@ pub async fn get_call_groups(user_id: i64) -> Vec<Arc<CallGroup>> {
|
|||
call_groups
|
||||
}
|
||||
|
||||
pub async fn get_call_token(user_id: i64, call_id: Uuid) -> Option<String> {
|
||||
pub async fn get_call_token(user_id: u64, call_id: Uuid) -> Option<String> {
|
||||
if let Some(cg) = CALL_GROUPS.get(&call_id) {
|
||||
let mut members = cg.members.write().await;
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ pub async fn get_call_token(user_id: i64, call_id: Uuid) -> Option<String> {
|
|||
Some(caller.create_token())
|
||||
}
|
||||
|
||||
pub async fn add_invite(call_id: Uuid, inviter_id: i64, invitee_id: i64) -> bool {
|
||||
pub async fn add_invite(call_id: Uuid, inviter_id: u64, invitee_id: u64) -> bool {
|
||||
if let Some(cg) = CALL_GROUPS.get(&call_id) {
|
||||
let mut members = cg.members.write().await;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ pub fn get_livekit() -> Result<(String, String, String), ()> {
|
|||
Ok((hostname, api_key, api_secret))
|
||||
}
|
||||
|
||||
pub fn create_token(user_id: i64, call_id: Uuid, has_admin: bool) -> Result<String, ()> {
|
||||
pub fn create_token(user_id: u64, call_id: Uuid, has_admin: bool) -> Result<String, ()> {
|
||||
let (_, api_key, api_secret) = get_livekit()?;
|
||||
|
||||
let token = access_token::AccessToken::with_api_key(&api_key, &api_secret)
|
||||
|
|
@ -69,7 +69,7 @@ pub async fn get_room(call_id: Uuid) -> Result<(RoomClient, Room), ()> {
|
|||
return Err(());
|
||||
}
|
||||
|
||||
pub async fn remove_participant(call_id: Uuid, user_id: i64) -> Result<(), ()> {
|
||||
pub async fn remove_participant(call_id: Uuid, user_id: u64) -> Result<(), ()> {
|
||||
if let Ok((hostname, api_key, api_secret)) = get_livekit() {
|
||||
let room_service = RoomClient::with_api_key(&hostname, &api_key, &api_secret);
|
||||
if let Ok(_) = room_service
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ use uuid::Uuid;
|
|||
use crate::calls::call_util;
|
||||
|
||||
pub struct Caller {
|
||||
pub user_id: i64,
|
||||
pub user_id: u64,
|
||||
pub call_id: Uuid,
|
||||
pub has_admin: bool,
|
||||
pub timeout: RwLock<i64>,
|
||||
}
|
||||
|
||||
impl Caller {
|
||||
pub fn new(user_id: i64, call_id: Uuid, has_admin: bool) -> Self {
|
||||
pub fn new(user_id: u64, call_id: Uuid, has_admin: bool) -> Self {
|
||||
Caller {
|
||||
user_id,
|
||||
call_id,
|
||||
|
|
|
|||
Loading…
Reference in a new issue