[Fix] Add chats, propper rho selection
This commit is contained in:
parent
60c980ba9a
commit
05006980f7
5 changed files with 36 additions and 16 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
|
@ -438,9 +438,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d"
|
||||
checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
|
@ -3131,7 +3131,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
|||
[[package]]
|
||||
name = "ttp-core"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/Tensamin/TTP.git#c127d196082401f37b51ca5417b341ecbdb74318"
|
||||
source = "git+https://github.com/Tensamin/TTP.git#9c0ed7a5b6c8735e4b674d4503bd7b936ee3656b"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"byteorder",
|
||||
|
|
@ -3143,7 +3143,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ttp-native"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/Tensamin/TTP.git#c127d196082401f37b51ca5417b341ecbdb74318"
|
||||
source = "git+https://github.com/Tensamin/TTP.git#9c0ed7a5b6c8735e4b674d4503bd7b936ee3656b"
|
||||
dependencies = [
|
||||
"quinn",
|
||||
"rustls",
|
||||
|
|
|
|||
|
|
@ -469,10 +469,31 @@ impl OmegaConnection {
|
|||
|
||||
let msg_id = cv.get_id();
|
||||
if let Some((_, task)) = WAITING_TASKS.remove(&msg_id) {
|
||||
if (task.task)(self.clone(), cv) {
|
||||
if (task.task)(self.clone(), cv.clone()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if cv.is_type(CommunicationType::iota_user_data) {
|
||||
if let DataValue::Array(users) = cv.get_data(DataTypes::user_ids) {
|
||||
let mut user_ids: Vec<u64> = Vec::new();
|
||||
for value in users {
|
||||
if let DataValue::Number(user_id) = value {
|
||||
user_ids.push(*user_id as u64);
|
||||
}
|
||||
}
|
||||
let connections = crate::rho::rho_manager::RHO_CONNECTIONS.read().await;
|
||||
if let Some(iota_id) = cv.get_data(DataTypes::iota_id).as_number() {
|
||||
if let Some(rho) = connections.get(&iota_id) {
|
||||
rho.get_iota_connection().set_user_ids(user_ids).await;
|
||||
}
|
||||
} else {
|
||||
for rho in connections.values() {
|
||||
rho.get_iota_connection().set_user_ids(user_ids.clone()).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log_err!(0, PrintType::Omega, "Receive error: {}", e);
|
||||
|
|
|
|||
|
|
@ -412,7 +412,7 @@ impl ClientConnection {
|
|||
&& cv
|
||||
.get_data(DataTypes::chat_partner_id)
|
||||
.as_number()
|
||||
.is_some()
|
||||
.is_none()
|
||||
{
|
||||
let chat_partner_name = cv
|
||||
.get_data(DataTypes::chat_partner_name)
|
||||
|
|
|
|||
|
|
@ -270,6 +270,9 @@ impl GeneralConnection {
|
|||
|
||||
let user_id = id as i64;
|
||||
|
||||
let client = ClientConnection::from_general(self.clone(), id).await;
|
||||
client.clone().start();
|
||||
|
||||
let mut rho = rho_manager::get_rho_con_for_user(user_id).await;
|
||||
|
||||
if rho.is_none() {
|
||||
|
|
@ -295,12 +298,10 @@ impl GeneralConnection {
|
|||
|
||||
*self.rho_connection.write().await = rho.clone();
|
||||
|
||||
let client = ClientConnection::from_general(self.clone(), id).await;
|
||||
|
||||
if let Some(rho_conn) = rho {
|
||||
// Make sure user is bound before the client starts forwarding
|
||||
rho_conn.bind_user_id(user_id).await;
|
||||
rho_conn.add_client_connection(client.clone()).await;
|
||||
rho_conn.add_client_connection(client).await;
|
||||
} else {
|
||||
log_err!(
|
||||
user_id,
|
||||
|
|
@ -309,8 +310,6 @@ impl GeneralConnection {
|
|||
id
|
||||
);
|
||||
}
|
||||
|
||||
client.start();
|
||||
}
|
||||
ConnectionKind::Iota => {
|
||||
let notify = CommunicationValue::new(CommunicationType::iota_connected)
|
||||
|
|
@ -323,6 +322,10 @@ impl GeneralConnection {
|
|||
|
||||
iota.set_rho_connection(rho.clone()).await;
|
||||
|
||||
rho_manager::add_rho(rho).await;
|
||||
|
||||
iota.clone().start();
|
||||
|
||||
let get_iota_msg = CommunicationValue::new(CommunicationType::get_iota_data)
|
||||
.add_data(DataTypes::iota_id, DataValue::Number(id as i64));
|
||||
|
||||
|
|
@ -340,10 +343,6 @@ impl GeneralConnection {
|
|||
iota.set_user_ids(user_ids).await;
|
||||
}
|
||||
}
|
||||
|
||||
rho_manager::add_rho(rho).await;
|
||||
|
||||
iota.start();
|
||||
}
|
||||
ConnectionKind::AnonymousClient => {
|
||||
let client = AnonymousClientConnection::from_general(self.clone(), id).await;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ impl IotaConnection {
|
|||
|
||||
if let Some(rho_conn) = self.get_rho_connection().await {
|
||||
let user_ids_i64: Vec<i64> = user_ids.into_iter().map(|u| u as i64).collect();
|
||||
rho_conn.set_user_ids(user_ids_i64);
|
||||
rho_conn.set_user_ids(user_ids_i64).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue