Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/Cocoon/
ExtensionHostMessage.rs

1//! Wire method: `cocoon:extensionHostMessage`.
2//! Relays binary extension-host protocol messages from Wind/Sky to Cocoon via
3//! gRPC GenericNotification. Fire-and-forget - the extension host protocol is
4//! fully async; Mountain does not await a reply.
5
6use serde_json::Value;
7use tauri::AppHandle;
8
9use crate::IPC::WindServiceHandlers::Utilities::JsonValueHelpers::arg_val;
10
11pub async fn Fn(_ApplicationHandle:AppHandle, Arguments:Vec<Value>) -> Result<Value, String> {
12	let ByteCount = Arguments
13		.first()
14		.map(|P| P.get("data").and_then(|D| D.as_array()).map(|A| A.len()).unwrap_or(0))
15		.unwrap_or(0);
16
17	crate::dev_log!("exthost", "cocoon:extensionHostMessage bytes={}", ByteCount);
18
19	let Payload = arg_val(&Arguments, 0);
20
21	tokio::spawn(async move {
22		if let Err(Error) = crate::Vine::Client::SendNotification::Fn(
23			"cocoon-main".to_string(),
24			"extensionHostMessage".to_string(),
25			Payload,
26		)
27		.await
28		{
29			crate::dev_log!("exthost", "cocoon:extensionHostMessage forward failed: {}", Error);
30		}
31	});
32
33	Ok(Value::Null)
34}