Skip to content

Commit 76a9cde

Browse files
iScorpiosaghul
authored andcommitted
ios: fix data channels not opening
1 parent b3a3898 commit 76a9cde

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

RTCPeerConnection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export default class RTCPeerConnection extends EventTarget(PEER_CONNECTION_EVENT
386386
// is reserved due to SCTP INIT and INIT-ACK chunks only allowing a
387387
// maximum of 65535 streams to be negotiated (as defined by the WebRTC
388388
// Data Channel Establishment Protocol).
389-
for (id = 0; id < 65535 && dataChannelIds.has(id); ++id);
389+
for (id = 1; id < 65535 && dataChannelIds.has(id); ++id);
390390
// TODO Throw an error if no unused id is available.
391391
dataChannelDict = Object.assign({id}, dataChannelDict);
392392
}

ios/RCTWebRTC/WebRTCModule+RTCDataChannel.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ @implementation WebRTCModule (RTCDataChannel)
2929
{
3030
RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
3131
RTCDataChannel *dataChannel = [peerConnection dataChannelForLabel:label configuration:config];
32-
// XXX RTP data channels are not defined by the WebRTC standard, have been
33-
// deprecated in Chromium, and Google have decided (in 2015) to no longer
34-
// support them (in the face of multiple reported issues of breakages).
35-
if (-1 != dataChannel.channelId) {
32+
if (dataChannel != nil && (dataChannel.readyState == RTCDataChannelStateConnecting
33+
|| dataChannel.readyState == RTCDataChannelStateOpen)) {
3634
dataChannel.peerConnectionId = peerConnectionId;
37-
NSNumber *dataChannelId = [NSNumber numberWithInteger:dataChannel.channelId];
35+
NSNumber *dataChannelId = [NSNumber numberWithInteger:config.channelId];
3836
peerConnection.dataChannels[dataChannelId] = dataChannel;
3937
dataChannel.delegate = self;
4038
}

0 commit comments

Comments
 (0)