feature(sender,receiver): added better functionality to separate room-ids

This commit is contained in:
Patryk Hegenberg 2024-05-01 22:38:18 +02:00
parent 34024055ad
commit 19f6b24e0f
7 changed files with 92 additions and 37 deletions

View file

@ -4,11 +4,17 @@ use serde::{Deserialize, Serialize};
pub struct TransferRequest {
pub name: String,
pub ip: String,
pub room_id: String,
pub local_room_id: String,
pub relay_room_id: String,
}
impl TransferRequest {
pub fn new(name: String, ip: String, room_id: String) -> Self {
Self { name, ip, room_id }
pub fn new(name: String, ip: String, local_room_id: String, relay_room_id: String) -> Self {
Self {
name,
ip,
local_room_id,
relay_room_id,
}
}
}
@ -16,12 +22,18 @@ impl TransferRequest {
pub struct TransferResponse {
pub name: String,
pub ip: String,
pub room_id: Vec<String>,
pub local_room_id: String,
pub relay_room_id: String,
}
impl TransferResponse {
pub fn new(name: String, ip: String, room_id: Vec<String>) -> Self {
Self { name, ip, room_id }
pub fn new(name: String, ip: String, local_room_id: String, relay_room_id: String) -> Self {
Self {
name,
ip,
local_room_id,
relay_room_id,
}
}
}
#[cfg(test)]
@ -33,13 +45,15 @@ mod tests {
let transfer = TransferResponse {
name: "Test".to_string(),
ip: "127.0.0.1".to_string(),
room_id: vec!["This_is_a_test_room_id".to_string()],
local_room_id: "This_is_a_test_room_id".to_string(),
relay_room_id: "This_is_a_test_room_id".to_string(),
};
assert_eq!(
TransferResponse::new(
"Test".to_string(),
"127.0.0.1".to_string(),
vec!["This_is_a_test_room_id".to_string()],
"This_is_a_test_room_id".to_string(),
"This_is_a_test_room_id".to_string(),
),
transfer
)