From 5c2ffedd115b580e2e88f8d2e3fb31cf5fae57a7 Mon Sep 17 00:00:00 2001 From: wxyz-abcd Date: Sun, 17 Nov 2024 05:39:26 +0300 Subject: [PATCH] dataChannel.onMessage binaryType=="arraybuffer" fix --- src/polyfill/RTCDataChannel.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/polyfill/RTCDataChannel.ts b/src/polyfill/RTCDataChannel.ts index 7515b2a..70756af 100644 --- a/src/polyfill/RTCDataChannel.ts +++ b/src/polyfill/RTCDataChannel.ts @@ -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 }));