Skip to content

Commit 6507c59

Browse files
committed
fix: fix bug for dc.onMessage.
1 parent a76eebb commit 6507c59

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22

33
--------------------------------------------
4+
[1.5.3+hotfix.2] - 2025-04-25
5+
6+
* fix bug for dc.onMessage.
7+
48
[1.5.3+hotfix.1] - 2025-04-25
59

610
* add getter override for dc.bufferedAmountLowThreshold.

lib/src/rtc_data_channel_impl.dart

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:async';
22
import 'dart:js_interop';
3+
import 'dart:typed_data';
34

45
import 'package:web/web.dart' as web;
56
import 'package:webrtc_interface/webrtc_interface.dart';
@@ -70,15 +71,13 @@ class RTCDataChannelWeb extends RTCDataChannel {
7071
if (data is String) {
7172
return RTCDataChannelMessage(data);
7273
}
73-
dynamic arrayBuffer;
74-
if (data is JSArrayBuffer) {
75-
arrayBuffer = data.toDart;
74+
if (data is ByteBuffer) {
75+
return RTCDataChannelMessage.fromBinary(data.asUint8List());
7676
} else if (data is web.Blob) {
77-
arrayBuffer = await data.arrayBuffer().toDart;
78-
} else {
79-
arrayBuffer = data.toDart;
77+
final arrayBuffer = await data.arrayBuffer().toDart;
78+
return RTCDataChannelMessage.fromBinary(arrayBuffer.toDart.asUint8List());
8079
}
81-
return RTCDataChannelMessage.fromBinary(arrayBuffer.asUint8List());
80+
return RTCDataChannelMessage.fromBinary(Uint8List(0));
8281
}
8382

8483
@override

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dart_webrtc
22
description: Use the dart/js library to re-wrap the webrtc js interface of the browser, to adapted common browsers.
3-
version: 1.5.3+hotfix.1
3+
version: 1.5.3+hotfix.2
44
homepage: https://github.com/flutter-webrtc/dart-webrtc
55

66
environment:

0 commit comments

Comments
 (0)