Implement script-to-host messaging #33

Closed
opened 2022-11-10 18:14:03 +00:00 by mars · 0 comments
Owner

Add a new ABI function (panel_send_message) to send messages (as byte pointers plus byte length) back to a panel (identified with the ID given during bind_panel).

The host-side ScriptAbi struct will need to have a VecDeque of Vec<u8>s for each panel ID. The panel_send_message function will push a copied byte array from the script to the deque.

canary::Panel will need a new function to read messages (pop messages from the deque) from the script. Usage looks like:

while let Some(message) = panel.recv_message() {
    println!("Received a message: {:?}", message);
}

Signature is Panel::recv_message(&self) -> Option<Vec<u8>>.

Magpie will need a new MagpieClientMsg kind to send messages to the client. Panel messages should be flushed after every event (update, draw, etc.). The window store will need to send messages received back to the IPC thread using a new variant of IpcMessage.

magpie::protocol::Messenger already implements the client-side packet receiving logic.

Add a new ABI function (`panel_send_message`) to send messages (as byte pointers plus byte length) back to a panel (identified with the ID given during `bind_panel`). The host-side `ScriptAbi` struct will need to have a `VecDeque` of `Vec<u8>`s for each panel ID. The `panel_send_message` function will push a copied byte array from the script to the deque. `canary::Panel` will need a new function to read messages (pop messages from the deque) from the script. Usage looks like: ```rs while let Some(message) = panel.recv_message() { println!("Received a message: {:?}", message); } ``` Signature is `Panel::recv_message(&self) -> Option<Vec<u8>>`. Magpie will need a new `MagpieClientMsg` kind to send messages to the client. Panel messages should be flushed after every event (`update`, `draw`, etc.). The window store will need to send messages received back to the IPC thread using a new variant of `IpcMessage`. `magpie::protocol::Messenger` already implements the client-side packet receiving logic.
mars added the
feature
api change
labels 2022-11-10 18:14:03 +00:00
mars closed this issue 2022-11-20 19:06:03 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: canary/canary-rs#33
No description provided.