Add init_msg to Magpie CreatePanel message

This commit is contained in:
mars 2022-12-06 16:59:06 -07:00
parent 14f077ff97
commit 780f13a015
3 changed files with 6 additions and 1 deletions

View File

@ -26,6 +26,7 @@ pub struct CreatePanel {
pub id: PanelId,
pub protocol: String,
pub script: PathBuf,
pub init_msg: Vec<u8>,
}
/// Sends a panel a message.

View File

@ -130,6 +130,7 @@ impl Client {
id,
protocol,
script,
init_msg,
}) => {
let mut data = self.data.write();
@ -146,6 +147,7 @@ impl Client {
id: window,
protocol,
script,
init_msg,
};
let _ = self.window_sender.send_event(msg);
}

View File

@ -21,6 +21,7 @@ pub enum WindowMessage {
id: usize,
protocol: String,
script: PathBuf,
init_msg: Vec<u8>,
},
CloseWindow {
id: usize,
@ -194,11 +195,12 @@ impl WindowStore {
id,
protocol,
script,
init_msg,
} => {
println!("Opening window {} with script {:?}", id, script);
let module = std::fs::read(script)?;
let mut script = self.runtime.load_module(&module)?;
let panel = script.create_panel(&protocol, vec![])?;
let panel = script.create_panel(&protocol, init_msg)?;
let window = Window::new(self.ipc_sender.to_owned(), id, panel, &event_loop)?;
let window_id = window.get_id();
self.windows.insert(window_id, window);