From bb6416bf0032d5c4bb2e6818b7a354b541abeead Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Wed, 24 Apr 2024 06:51:59 +0800 Subject: [PATCH] fix dc parse. --- lib/src/rtc_data_channel_impl.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/rtc_data_channel_impl.dart b/lib/src/rtc_data_channel_impl.dart index a9ab3f7..08855f7 100644 --- a/lib/src/rtc_data_channel_impl.dart +++ b/lib/src/rtc_data_channel_impl.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:js_interop'; +import 'package:js/js_util.dart' as jsutil; import 'package:web/web.dart' as web; import 'package:webrtc_interface/webrtc_interface.dart'; @@ -71,8 +72,11 @@ class RTCDataChannelWeb extends RTCDataChannel { dynamic arrayBuffer; if (data is JSArrayBuffer) { arrayBuffer = data.toDart; + } else if (data is web.Blob) { + arrayBuffer = await jsutil + .promiseToFuture(jsutil.callMethod(data, 'arrayBuffer', [])); } else { - arrayBuffer = data.toString(); + arrayBuffer = data.toDart; } return RTCDataChannelMessage.fromBinary(arrayBuffer.asUint8List()); }