From 54fbd2c2d1d4fc408cb1a21e4f0394bc2612beb4 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Tue, 30 Aug 2022 21:56:08 +0900
Subject: [PATCH] Fix message event in FakeRTCDataChannel
---
lib/FakeRTCDataChannel.js | 4 ++--
src/FakeRTCDataChannel.ts | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/FakeRTCDataChannel.js b/lib/FakeRTCDataChannel.js
index d44a9a7..5306631 100644
--- a/lib/FakeRTCDataChannel.js
+++ b/lib/FakeRTCDataChannel.js
@@ -166,7 +166,7 @@ class FakeRTCDataChannel extends event_target_shim_1.EventTarget {
case 'message':
{
// @ts-ignore
- this.dispatchEvent(new event_target_shim_1.Event('message', { data }));
+ this.dispatchEvent(new MessageEvent('message', { data }));
break;
}
case 'binary':
@@ -178,7 +178,7 @@ class FakeRTCDataChannel extends event_target_shim_1.EventTarget {
view[i] = buffer[i];
}
// @ts-ignore
- this.dispatchEvent(new event_target_shim_1.Event('message', { data: arrayBuffer }));
+ this.dispatchEvent(new MessageEvent('message', { data: arrayBuffer }));
break;
}
case 'bufferedamountlow':
diff --git a/src/FakeRTCDataChannel.ts b/src/FakeRTCDataChannel.ts
index 9684ea3..8cbaa95 100644
--- a/src/FakeRTCDataChannel.ts
+++ b/src/FakeRTCDataChannel.ts
@@ -298,7 +298,7 @@ export class FakeRTCDataChannel extends EventTarget implements RTCDataChannel
case 'message':
{
// @ts-ignore
- this.dispatchEvent(new Event('message', { data }));
+ this.dispatchEvent(new MessageEvent('message', { data }));
break;
}
@@ -315,7 +315,7 @@ export class FakeRTCDataChannel extends EventTarget implements RTCDataChannel
}
// @ts-ignore
- this.dispatchEvent(new Event('message', { data: arrayBuffer }));
+ this.dispatchEvent(new MessageEvent('message', { data: arrayBuffer }));
break;
}