8000 fix: fix wrong id type for data-channel. (#924) · sujeking/flutter-webrtc@362587f · GitHub
[go: up one dir, main page]

Skip to content

Commit 362587f

Browse files
authored
fix: fix wrong id type for data-channel. (flutter-webrtc#924)
* fix: fix wrong id type for data-channel. * chore: `run import_sorter:main --no-comments`
1 parent 8a14779 commit 362587f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/src/native/rtc_data_channel_impl.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class RTCDataChannelNative extends RTCDataChannel {
5151
final Map<dynamic, dynamic> map = event;
5252
switch (map['event']) {
5353
case 'dataChannelStateChanged':
54-
_dataChannelId = int.tryParse(map['id']);
54+
_dataChannelId = map['id'];
5555
_state = rtcDataChannelStateForString(map['state']);
5656
onDataChannelState?.call(_state!);
5757

test/unit/rtc_peerconnection_test.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/services.dart';
22

33
import 'package:flutter_test/flutter_test.dart';
44

5+
import 'package:flutter_webrtc/src/native/rtc_data_channel_impl.dart';
56
import 'package:flutter_webrtc/src/native/rtc_peerconnection_impl.dart';
67

78
void main() {
@@ -25,7 +26,7 @@ void main() {
2526
test(
2627
'Validate that not setting any public delegate this will not break the implementation by throwing NPE',
2728
() {
28-
final rct = RTCPeerConnectionNative('', {});
29+
final pc = RTCPeerConnectionNative('', {});
2930
final events = [
3031
'signalingState',
3132
'iceGatheringState',
@@ -39,8 +40,17 @@ void main() {
3940
'onRenegotiationNeeded'
4041
];
4142

43+
pc.onDataChannel = (dc) {
44+
final channel = dc as RTCDataChannelNative;
45+
channel.eventListener(<String, dynamic>{
46+
'event': 'dataChannelStateChanged',
47+
'id': 0,
48+
'state': 'open'
49+
});
50+
};
51+
4252
events.forEach((event) {
43-
rct.eventListener(<String, dynamic>{
53+
pc.eventListener(<String, dynamic>{
4454
'event': event,
4555

4656
//Minimum values for signalingState, iceGatheringState, iceConnectionState

0 commit comments

Comments
 (0)
0