handle RTC ArrayBuffers with explicit check

This commit is contained in:
Spencer Pogorzelski 2023-08-14 10:51:49 -07:00
parent ae6c3061fa
commit afe01cce3c

View file

@ -111,8 +111,12 @@ async function answerRtc(data: any, onrespond: (answer: any) => void) {
}; };
dataChannel.onmessage = (event) => { dataChannel.onmessage = (event) => {
console.log("messaged"); console.log("messaged");
if (event.data instanceof ArrayBuffer) {
server.onMsg(event.data);
}
if (event.data instanceof Buffer) { if (event.data instanceof Buffer) {
server.onMsg(bufferToArrayBuffer(event.data)); server.onMsg(bufferToArrayBuffer(event.data));
return;
} }
throw new Error("Unexpected datachannel message type"); throw new Error("Unexpected datachannel message type");
}; };