mirror of
https://github.com/sr229/kuru-kuru.git
synced 2024-09-20 04:10:33 +00:00
Fix BroadcastChannel sending Encoded bytes
This commit is contained in:
parent
4ea19cd5a0
commit
c6f3decb45
1 changed files with 5 additions and 2 deletions
|
@ -34,6 +34,7 @@ export const handler: Handlers = {
|
||||||
};
|
};
|
||||||
|
|
||||||
bc.addEventListener("message", (e) => {
|
bc.addEventListener("message", (e) => {
|
||||||
|
console.log(e);
|
||||||
socket.send(JSON.stringify({ globalCount: e.data }));
|
socket.send(JSON.stringify({ globalCount: e.data }));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -66,8 +67,10 @@ export const handler: Handlers = {
|
||||||
const body = await req.json();
|
const body = await req.json();
|
||||||
await setGlobalStatistics(body.data);
|
await setGlobalStatistics(body.data);
|
||||||
|
|
||||||
|
const updatedCount = await getGlobalStatistics();
|
||||||
|
|
||||||
const bc = new BroadcastChannel("global-count");
|
const bc = new BroadcastChannel("global-count");
|
||||||
bc.postMessage(new TextEncoder().encode(getGlobalStatistics().toString()));
|
bc.postMessage(updatedCount.toString());
|
||||||
|
|
||||||
return new Response("", {
|
return new Response("", {
|
||||||
status: 200,
|
status: 200,
|
||||||
|
|
Loading…
Reference in a new issue