feat: move call sound to server
This commit is contained in:
6
index.ts
6
index.ts
@@ -94,6 +94,12 @@ Bun.serve({
|
||||
}
|
||||
} else if (data.type == "rooms") {
|
||||
ws.send(JSON.stringify({ type: "rooms", rooms: ROOMS }));
|
||||
} else if (data.type == "call-audio") {
|
||||
// Send the call.wav file as data URI
|
||||
const file = await Bun.file("./call.wav").arrayBuffer();
|
||||
const base64 = Buffer.from(file).toString("base64");
|
||||
const dataUri = `data:audio/wav;base64,${base64}`;
|
||||
ws.send(JSON.stringify({ type: "call-audio", dataUri }));
|
||||
}
|
||||
}, // a message is received
|
||||
open(ws) {
|
||||
|
||||
Reference in New Issue
Block a user