[Add] get call_data handling
This commit is contained in:
parent
07bb2c6be6
commit
a9d8187db4
2 changed files with 53 additions and 2 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -3279,7 +3279,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
|||
[[package]]
|
||||
name = "ttp-core"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.methanium.net/Tensamin/TTP.git#d8d82e108ae4e25ad34947e03e917528407e43f3"
|
||||
source = "git+https://git.methanium.net/Tensamin/TTP.git#01cefdf60d77b39565d662f5b585058a2b62decf"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"byteorder",
|
||||
|
|
@ -3292,7 +3292,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ttp-native"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.methanium.net/Tensamin/TTP.git#d8d82e108ae4e25ad34947e03e917528407e43f3"
|
||||
source = "git+https://git.methanium.net/Tensamin/TTP.git#01cefdf60d77b39565d662f5b585058a2b62decf"
|
||||
dependencies = [
|
||||
"quinn",
|
||||
"rustls",
|
||||
|
|
|
|||
|
|
@ -119,6 +119,11 @@ impl ClientConnection {
|
|||
return;
|
||||
}
|
||||
|
||||
if cv.is_type(CommunicationType::call_data) {
|
||||
self.handle_get_call_data(cv).await;
|
||||
return;
|
||||
}
|
||||
|
||||
if cv.is_type(CommunicationType::call_disconnect_user) {
|
||||
self.handle_call_disconnect_user(cv).await;
|
||||
return;
|
||||
|
|
@ -342,6 +347,52 @@ impl ClientConnection {
|
|||
return;
|
||||
}
|
||||
}
|
||||
async fn handle_get_call_data(self: Arc<Self>, cv: CommunicationValue) {
|
||||
let user_id = self.get_user_id().await;
|
||||
|
||||
let call_id = match cv.get_data(DataTypes::call_id) {
|
||||
DataValue::Str(id_str) => match Uuid::parse_str(id_str.as_str()) {
|
||||
Ok(id) => id,
|
||||
Err(_) => {
|
||||
self.send_error_response(cv.get_id(), CommunicationType::error)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
self.send_error_response(cv.get_id(), CommunicationType::error)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(call) = call_manager::get_call(call_id).await {
|
||||
if let Some(_) = call.get_caller(user_id).await {
|
||||
let mut user_ids: Vec<DataValue> = Vec::new();
|
||||
let members = call.members.read().await.clone();
|
||||
for member in members {
|
||||
if member.user_id == user_id {
|
||||
user_ids.push(DataValue::Number(member.user_id as i64));
|
||||
}
|
||||
}
|
||||
|
||||
let response = CommunicationValue::new(CommunicationType::call_token)
|
||||
.with_id(cv.get_id())
|
||||
.with_receiver(user_id as u64)
|
||||
.add_data(DataTypes::user_ids, DataValue::Array(user_ids));
|
||||
self.send_message(&response).await;
|
||||
} else {
|
||||
self.send_error_response(cv.get_id(), CommunicationType::error)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
self.send_error_response(cv.get_id(), CommunicationType::error)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_call_timeout_user(self: Arc<Self>, cv: CommunicationValue) {
|
||||
let call_id =
|
||||
Uuid::from_str(cv.get_data(DataTypes::call_id).as_str().unwrap_or("")).unwrap();
|
||||
|
|
|
|||
Loading…
Reference in a new issue