I am using ISBX/apprtc-ios code for video chat implementation. This work perfect in iPhone and simulator. I want to send text/string data between two peers and I am using RTCDataChannel
class.
Following is my implementation and I am not able to establish the connection. It always give the status kRTCDataChannelStateConnecting
How can I get the RTCDataChannel connected? Is there any working implementation available for WebRTC RTCDataChannel for iOS?
- (void)createNewDataChannel {
if (self.clientDataChannel) {
switch(self.clientDataChannel.state) {
case kRTCDataChannelStateConnecting:
NSLog(@"kRTCDataChannelStateConnecting");
break;
case kRTCDataChannelStateOpen:
NSLog(@"kRTCDataChannelStateOpen");
break;
case kRTCDataChannelStateClosing:
NSLog(@"kRTCDataChannelStateClosing");
break;
case kRTCDataChannelStateClosed:
NSLog(@"kRTCDataChannelStateClosed");
break;
default:
NSLog(@"Unknown");
}
return;
}
if (self.peerConnection == nil) {
NSLog(@"Peerconnection is nil");
}
RTCDataChannelInit *DataChannelInit = [[RTCDataChannelInit alloc] init];
DataChannelInit.maxRetransmits = 0;
DataChannelInit.isOrdered=false;
DataChannelInit.maxRetransmitTimeMs = -1;
DataChannelInit.isNegotiated = false;
DataChannelInit.streamId = 25;
RTCDataChannel *dataChannel =[_peerConnection createDataChannelWithLabel:@"commands" config:DataChannelInit];
dataChannel.delegate=self;
self.clientDataChannel = dataChannel;
if (self.clientDataChannel == nil) {
NSLog(@"Datachannel is nil");
}
else {
NSLog(@"Datachannel is working");
}
}
I am able to send data through RTCDataChannel. What I did is before sending the offer. I created the RTCDataChannelInit with the below configuration.
Once both the devices get connected, I checked the state in the delegate function. The state of the channel is open.
Then I send the data as per the below code:
The configuration I used was given here: https://groups.google.com/forum/#!searchin/discuss-webrtc/RTCDataChannel/discuss-webrtc/9NObqxnItCg/mRvXBIwkA7wJ