switch sides: use ipc to pass msg from ui to server

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-01-17 20:16:36 +08:00
parent 81a60725f4
commit e57949d472
4 changed files with 46 additions and 15 deletions

View File

@@ -208,7 +208,8 @@ pub enum Data {
Empty,
Disconnected,
DataPortableService(DataPortableService),
SwitchBack,
SwitchSidesRequest(String),
SwitchSidesBack,
}
#[tokio::main(flavor = "current_thread")]
@@ -429,6 +430,15 @@ async fn handle(data: Data, stream: &mut Connection) {
Data::TestRendezvousServer => {
crate::test_rendezvous_server();
}
Data::SwitchSidesRequest(id) => {
let uuid = uuid::Uuid::new_v4();
crate::server::insert_switch_sides_uuid(id, uuid.clone());
allow_err!(
stream
.send(&Data::SwitchSidesRequest(uuid.to_string()))
.await
);
}
_ => {}
}
}