mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-19 03:01:02 +03:00
terminal works basically. (#12189)
* terminal works basically. todo: - persistent - sessions restore - web - mobile * missed terminal persistent option change * android sdk 34 -> 35 * +#![cfg_attr(lt_1_77, feature(c_str_literals))] * fixing ci * fix ci * fix ci for android * try "Fix Android SDK Platform 35" * fix android 34 * revert flutter_plugin_android_lifecycle to 2.0.17 which used in rustdesk 1.4.0 * refactor, but break something of desktop terminal (new tab showing loading) * fix connecting...
This commit is contained in:
@@ -1105,6 +1105,60 @@ impl InvokeUiSession for FlutterHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_terminal_response(&self, response: TerminalResponse) {
|
||||
use hbb_common::message_proto::terminal_response::Union;
|
||||
|
||||
match response.union {
|
||||
Some(Union::Opened(opened)) => {
|
||||
let mut event_data: Vec<(&str, serde_json::Value)> = vec![
|
||||
("type", json!("opened")),
|
||||
("terminal_id", json!(opened.terminal_id)),
|
||||
("success", json!(opened.success)),
|
||||
("message", json!(&opened.message)),
|
||||
("pid", json!(opened.pid)),
|
||||
("service_id", json!(&opened.service_id)),
|
||||
];
|
||||
self.push_event_("terminal_response", &event_data, &[], &[]);
|
||||
}
|
||||
Some(Union::Data(data)) => {
|
||||
// Decompress data if needed
|
||||
let output_data = if data.compressed {
|
||||
hbb_common::compress::decompress(&data.data)
|
||||
} else {
|
||||
data.data.to_vec()
|
||||
};
|
||||
|
||||
let encoded = crate::encode64(&output_data);
|
||||
let event_data: Vec<(&str, serde_json::Value)> = vec![
|
||||
("type", json!("data")),
|
||||
("terminal_id", json!(data.terminal_id)),
|
||||
("data", json!(&encoded)),
|
||||
];
|
||||
self.push_event_("terminal_response", &event_data, &[], &[]);
|
||||
}
|
||||
Some(Union::Closed(closed)) => {
|
||||
let event_data: Vec<(&str, serde_json::Value)> = vec![
|
||||
("type", json!("closed")),
|
||||
("terminal_id", json!(closed.terminal_id)),
|
||||
("exit_code", json!(closed.exit_code)),
|
||||
];
|
||||
self.push_event_("terminal_response", &event_data, &[], &[]);
|
||||
}
|
||||
Some(Union::Error(error)) => {
|
||||
let event_data: Vec<(&str, serde_json::Value)> = vec![
|
||||
("type", json!("error")),
|
||||
("terminal_id", json!(error.terminal_id)),
|
||||
("message", json!(&error.message)),
|
||||
];
|
||||
self.push_event_("terminal_response", &event_data, &[], &[]);
|
||||
}
|
||||
None => {}
|
||||
Some(_) => {
|
||||
log::warn!("Unhandled terminal response type");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FlutterHandler {
|
||||
@@ -1221,6 +1275,7 @@ pub fn session_add(
|
||||
is_view_camera: bool,
|
||||
is_port_forward: bool,
|
||||
is_rdp: bool,
|
||||
is_terminal: bool,
|
||||
switch_uuid: &str,
|
||||
force_relay: bool,
|
||||
password: String,
|
||||
@@ -1231,6 +1286,8 @@ pub fn session_add(
|
||||
ConnType::FILE_TRANSFER
|
||||
} else if is_view_camera {
|
||||
ConnType::VIEW_CAMERA
|
||||
} else if is_terminal {
|
||||
ConnType::TERMINAL
|
||||
} else if is_port_forward {
|
||||
if is_rdp {
|
||||
ConnType::RDP
|
||||
|
||||
Reference in New Issue
Block a user