diff options
| author | LLLL Colonq <llll@colonq> | 2026-08-17 20:14:16 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-08-17 20:14:16 -0400 |
| commit | de99c5f7636a952025ea13de02bafd25bcb6bdec (patch) | |
| tree | be359424af4f6717103e3b667b6529ae5a4b4e6a /2026/games_submissions/rpc2dot0/src/message.rs | |
| parent | 4d4d1f24721f27fbf37e1070be6414de130ace61 (diff) | |
Fix broken
Diffstat (limited to '2026/games_submissions/rpc2dot0/src/message.rs')
| -rw-r--r-- | 2026/games_submissions/rpc2dot0/src/message.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/2026/games_submissions/rpc2dot0/src/message.rs b/2026/games_submissions/rpc2dot0/src/message.rs new file mode 100644 index 0000000..d960b67 --- /dev/null +++ b/2026/games_submissions/rpc2dot0/src/message.rs @@ -0,0 +1,26 @@ +use serde::Serialize;
+use std::fmt::Debug;
+
+#[derive(Serialize, Debug)]
+pub struct Message<'a> {
+ pub op: &'a str,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub verb: Option<&'a str>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub win: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub score: Option<i32>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub video_url: Option<String>,
+}
+
+impl<'a> Message<'a> {
+ pub fn post<MSG>(window: &web_sys::Window, msg: &MSG)
+ where
+ MSG: Serialize + Debug,
+ {
+ log::info!("eatyourgreens:: post message: {:?}", msg);
+ let js_value = serde_wasm_bindgen::to_value(msg).unwrap();
+ let _ = window.post_message(&js_value, "*");
+ }
+}
|
