fix: browser returns a Blob, so convert to a buffer if we have a blob

This commit is contained in:
Derrick Hammer 2023-09-01 06:39:25 -04:00
parent 8b7ffa8821
commit 80dd92ddb1
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 7 additions and 1 deletions

View File

@ -24,7 +24,13 @@ export class WebSocketPeer extends BasePeer implements Peer {
this._socket.addEventListener( this._socket.addEventListener(
"message", "message",
async (event: MessageEvent<any>) => { async (event: MessageEvent<any>) => {
await callback(event.data); let data = event.data;
if (data instanceof Blob) {
data = Buffer.from(await data.arrayBuffer());
}
await callback(data);
}, },
); );