arrpc: fix link handling

This commit is contained in:
Vendicated
2025-07-06 17:54:23 +02:00
parent 8aa91b4f01
commit 4baf6de472
3 changed files with 23 additions and 15 deletions

View File

@@ -26,7 +26,8 @@ const linkCallbacks = new Map<string, LinkCallback>();
server.on("activity", (data: any) => {
const event: ArRpcEvent = {
type: "activity",
data: JSON.stringify(data)
data: JSON.stringify(data),
nonce: randomUUID()
};
workerPort.postMessage(event);
});
@@ -43,6 +44,18 @@ const linkCallbacks = new Map<string, LinkCallback>();
workerPort.postMessage(event);
});
server.on("link", async (data: any, callback: LinkCallback) => {
const nonce = randomUUID();
linkCallbacks.set(nonce, callback);
const event: ArRpcEvent = {
type: "link",
data,
nonce
};
workerPort.postMessage(event);
});
workerPort.on("message", (e: ArRpcHostEvent) => {
switch (e.type) {
case "ack-invite": {