Async Handling
This commit is contained in:
parent
d46836a219
commit
30cb6c5fa5
4 changed files with 36 additions and 36 deletions
|
|
@ -33,7 +33,8 @@ pub async fn get_call_groups(user_id: Uuid) -> Vec<Arc<CallGroup>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_call_token(user_id: Uuid, call_id: Uuid) -> Option<String> {
|
pub async fn get_call_token(user_id: Uuid, call_id: Uuid) -> Option<String> {
|
||||||
let call_groups = CALL_GROUPS.read().await;
|
let call_groups = { CALL_GROUPS.read().await.clone() };
|
||||||
|
|
||||||
for cg in call_groups.iter() {
|
for cg in call_groups.iter() {
|
||||||
if cg.call_id == call_id {
|
if cg.call_id == call_id {
|
||||||
for member in cg.members.read().await.iter() {
|
for member in cg.members.read().await.iter() {
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,14 @@ mod rho;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
use async_tungstenite::accept_hdr_async;
|
use async_tungstenite::accept_hdr_async;
|
||||||
|
use dotenv::dotenv;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use livekit_api::services::room::{CreateRoomOptions, RoomClient};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tokio_util::compat::TokioAsyncReadCompatExt;
|
use tokio_util::compat::TokioAsyncReadCompatExt;
|
||||||
use tungstenite::handshake::server::{Request, Response};
|
use tungstenite::handshake::server::{Request, Response};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
calls::call_util,
|
|
||||||
omega::omega_connection::OmegaConnection,
|
omega::omega_connection::OmegaConnection,
|
||||||
rho::{client_connection::ClientConnection, iota_connection::IotaConnection},
|
rho::{client_connection::ClientConnection, iota_connection::IotaConnection},
|
||||||
util::{
|
util::{
|
||||||
|
|
@ -25,6 +24,7 @@ use crate::{
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
dotenv().ok();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
OmegaConnection::new().connect().await;
|
OmegaConnection::new().connect().await;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ impl ClientConnection {
|
||||||
|
|
||||||
/// Handle incoming message from client
|
/// Handle incoming message from client
|
||||||
pub async fn handle_message(self: Arc<Self>, message: Utf8Bytes) {
|
pub async fn handle_message(self: Arc<Self>, message: Utf8Bytes) {
|
||||||
|
tokio::spawn(async move {
|
||||||
let cv = CommunicationValue::from_json(&message);
|
let cv = CommunicationValue::from_json(&message);
|
||||||
|
|
||||||
// Handle identification
|
// Handle identification
|
||||||
|
|
@ -147,7 +148,6 @@ impl ClientConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forward other messages to Iota
|
// Forward other messages to Iota
|
||||||
tokio::spawn(async move {
|
|
||||||
self.forward_to_iota(cv).await;
|
self.forward_to_iota(cv).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
use super::rho_connection::RhoConnection;
|
use super::rho_connection::RhoConnection;
|
||||||
use crate::util::print::PrintType;
|
use crate::util::print::PrintType;
|
||||||
use crate::util::print::line;
|
use crate::util::print::line;
|
||||||
use crate::util::print::line_err;
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
sync::{Arc, LazyLock},
|
sync::{Arc, LazyLock},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue