Calling Logging fixing
This commit is contained in:
parent
3c0344ef64
commit
3cb2f0ec5e
12 changed files with 118 additions and 112 deletions
|
|
@ -1,14 +1,13 @@
|
|||
use async_tungstenite::tungstenite::Message;
|
||||
use async_tungstenite::{WebSocketReceiver, WebSocketSender};
|
||||
use async_tungstenite::{WebSocketStream, tungstenite::Message};
|
||||
use futures::SinkExt;
|
||||
use std::sync::{Arc, Weak};
|
||||
use tokio::sync::Mutex;
|
||||
use tokio::sync::RwLock;
|
||||
use tokio_util::compat::Compat;
|
||||
use tungstenite::Utf8Bytes;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::{rho_connection::RhoConnection, rho_manager};
|
||||
use crate::calls::call_manager;
|
||||
use crate::util::print::PrintType;
|
||||
use crate::util::print::line;
|
||||
use crate::util::print::line_err;
|
||||
|
|
@ -154,7 +153,7 @@ impl ClientConnection {
|
|||
}
|
||||
|
||||
/// Handle identification message
|
||||
async fn handle_identification(&self, sarc: Arc<ClientConnection>, mut cv: CommunicationValue) {
|
||||
async fn handle_identification(&self, sarc: Arc<ClientConnection>, cv: CommunicationValue) {
|
||||
// Extract user ID
|
||||
let user_id = match cv.get_data(DataTypes::user_id) {
|
||||
Some(id_str) => match Uuid::parse_str(&id_str.to_string()) {
|
||||
|
|
@ -228,7 +227,7 @@ impl ClientConnection {
|
|||
}
|
||||
|
||||
/// Handle ping message
|
||||
async fn handle_ping(&self, mut cv: CommunicationValue) {
|
||||
async fn handle_ping(&self, cv: CommunicationValue) {
|
||||
// Update our ping if provided
|
||||
if let Some(last_ping) = cv.get_data(DataTypes::last_ping) {
|
||||
if let Ok(ping_val) = last_ping.to_string().parse::<i64>() {
|
||||
|
|
@ -253,9 +252,9 @@ impl ClientConnection {
|
|||
}
|
||||
|
||||
/// Handle client status change
|
||||
async fn handle_client_changed(&self, mut cv: CommunicationValue) {
|
||||
async fn handle_client_changed(&self, cv: CommunicationValue) {
|
||||
if let Some(user_id) = self.get_user_id().await {
|
||||
if let Some(status_str) = cv.get_data(DataTypes::user_state) {
|
||||
if let Some(_status_str) = cv.get_data(DataTypes::user_state) {
|
||||
// Parse user status - this would need to be implemented properly
|
||||
let user_status = UserStatus::online; // placeholder
|
||||
if let Some(rho_conn) = self.get_rho_connection().await {
|
||||
|
|
@ -359,7 +358,7 @@ impl ClientConnection {
|
|||
}
|
||||
|
||||
/// Handle get call request
|
||||
async fn handle_get_call(&self, mut cv: CommunicationValue) {
|
||||
async fn handle_get_call(&self, cv: CommunicationValue) {
|
||||
let user_id = match self.get_user_id().await {
|
||||
Some(id) => id,
|
||||
None => return,
|
||||
|
|
@ -396,24 +395,25 @@ impl ClientConnection {
|
|||
.with_id(cv.get_id())
|
||||
.with_receiver(user_id);
|
||||
|
||||
// Placeholder call group logic
|
||||
// if let Some(call_group) = CallManager::get_call_group(call_id, &call_secret_sha.unwrap(), true).await {
|
||||
// response = response
|
||||
// .add_data_str(DataTypes::call_state, call_group.call_state.to_string())
|
||||
// .add_data_str(DataTypes::start_date, call_group.started_at.to_string());
|
||||
//
|
||||
// if call_group.ended_at != 0 {
|
||||
// response = response.add_data_str(DataTypes::end_date, call_group.ended_at.to_string());
|
||||
// }
|
||||
// } else {
|
||||
response = response.add_data_str(DataTypes::call_state, "DESTROYED".to_string());
|
||||
// }
|
||||
if let Some(_call_group) = call_manager::get_group(call_id).await {
|
||||
/*response = response
|
||||
.add_data_str(DataTypes::call_state, call_group.call_state.to_string())
|
||||
.add_data_str(DataTypes::start_date, call_group.started_at.to_string());
|
||||
|
||||
if call_group.lock(). != 0 {
|
||||
response =
|
||||
response.add_data_str(DataTypes::end_date, call_group.ended_at.to_string());
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
response = response.add_data_str(DataTypes::call_state, "DESTROYED".to_string());
|
||||
}
|
||||
|
||||
self.send_message(&response).await;
|
||||
}
|
||||
|
||||
/// Forward message to Iota
|
||||
async fn forward_to_iota(&self, mut cv: CommunicationValue) {
|
||||
async fn forward_to_iota(&self, cv: CommunicationValue) {
|
||||
if let Some(user_id) = self.get_user_id().await {
|
||||
if let Some(rho_conn) = self.get_rho_connection().await {
|
||||
let updated_cv = cv.with_sender(user_id);
|
||||
|
|
|
|||
|
|
@ -1,19 +1,15 @@
|
|||
use crate::util::print::PrintType;
|
||||
use crate::util::print::line;
|
||||
use crate::util::print::line_err;
|
||||
use ansi_term::Color;
|
||||
use async_tungstenite::WebSocketReceiver;
|
||||
use async_tungstenite::WebSocketSender;
|
||||
use async_tungstenite::tungstenite::protocol::WebSocketConfig;
|
||||
use async_tungstenite::{WebSocketStream, tungstenite::Message};
|
||||
use futures::FutureExt;
|
||||
use futures::SinkExt;
|
||||
use async_tungstenite::tungstenite::Message;
|
||||
use json::JsonValue;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::{Arc, Weak},
|
||||
};
|
||||
use tokio::sync::{Mutex, RwLock};
|
||||
use tokio::sync::RwLock;
|
||||
use tokio_util::compat::Compat;
|
||||
use tungstenite::Utf8Bytes;
|
||||
use uuid::Uuid;
|
||||
|
|
@ -280,12 +276,12 @@ impl IotaConnection {
|
|||
}
|
||||
|
||||
/// Handle GET_CHATS message
|
||||
async fn handle_get_chats(&self, mut cv: CommunicationValue) {
|
||||
async fn handle_get_chats(&self, cv: CommunicationValue) {
|
||||
let receiver_id = cv.get_receiver();
|
||||
let mut interested_ids: Vec<Uuid> = Vec::new();
|
||||
let interested_ids: Vec<Uuid> = Vec::new();
|
||||
|
||||
// Process contacts and add call information
|
||||
if let Some(contacts_data) = cv.get_data(DataTypes::user_ids) {
|
||||
if let Some(_contacts_data) = cv.get_data(DataTypes::user_ids) {
|
||||
// Parse contacts JSON array and enrich with call data
|
||||
// This would need proper JSON parsing implementation
|
||||
// For now, placeholder logic:
|
||||
|
|
@ -321,7 +317,7 @@ impl IotaConnection {
|
|||
async fn forward_to_client(&self, cv: CommunicationValue) {
|
||||
if let Some(rho_conn) = self.get_rho_connection().await {
|
||||
let updated_cv = cv.with_sender(self.get_iota_id().await);
|
||||
let receiver_id = updated_cv.get_receiver();
|
||||
let _receiver_id = updated_cv.get_receiver();
|
||||
rho_conn.message_to_client(updated_cv).await;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,6 @@ use crate::data::{
|
|||
user::UserStatus,
|
||||
};
|
||||
use crate::omega::omega_connection::OmegaConnection;
|
||||
use crate::util::print::PrintType;
|
||||
use crate::util::print::line;
|
||||
use crate::util::print::line_err;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
|
|
|||
|
|
@ -68,36 +68,3 @@ pub async fn connection_count() -> usize {
|
|||
let connections = RHO_CONNECTIONS.read().await;
|
||||
connections.len()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::rho::iota_connection::IotaConnection;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_add_and_get_rho() {
|
||||
// Clear any existing connections
|
||||
{
|
||||
let mut connections = RHO_CONNECTIONS.write().await;
|
||||
connections.clear();
|
||||
}
|
||||
|
||||
let iota_id = Uuid::new_v4();
|
||||
let user_ids = vec![Uuid::new_v4(), Uuid::new_v4()];
|
||||
|
||||
// Skip this test due to WebSocket complexity - would require proper mock setup
|
||||
return;
|
||||
|
||||
// This test would need proper WebSocket stream mocking:
|
||||
// let mock_session = create_mock_websocket_stream();
|
||||
// let iota_conn = IotaConnection::new_with_ids(iota_id, user_ids.clone(), mock_session);
|
||||
// let rho_conn = Arc::new(RhoConnection::new(iota_conn, user_ids.clone()));
|
||||
|
||||
// Test assertions would go here:
|
||||
// add_rho(Arc::clone(&rho_conn)).await;
|
||||
// assert!(contains_iota(iota_id).await);
|
||||
// etc.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue