Skip to content

Commit

Permalink
dataChannel.onMessage binaryType=="arraybuffer" fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wxyz-abcd authored Nov 17, 2024
1 parent be38609 commit 5c2ffed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/polyfill/RTCDataChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export default class RTCDataChannel extends EventTarget implements globalThis.RT

this.#dataChannel.onMessage((data) => {
if (ArrayBuffer.isView(data)) {
data = Buffer.from(data.buffer);
if (this.binaryType=="arraybuffer")
data = data.buffer;
else
data = Buffer.from(data);
}

this.dispatchEvent(new MessageEvent('message', { data }));
Expand Down

0 comments on commit 5c2ffed

Please sign in to comment.