RTCDataChannel不工作的iOS

我正在使用RTCDataChannel。 但是我通过频道发送的消息在另一个同伴没有收到。

这里是代码:

let audioConstraint : RTCPair = RTCPair(key: "OfferToReceiveAudio", value: "true") let videoConstraint : RTCPair = RTCPair(key: "OfferToReceiveVideo", value: "true") let dtlsConstraint : RTCPair = RTCPair(key: "DtlsSrtpKeyAgreement", value: "true") let mediaContraints : RTCMediaConstraints = RTCMediaConstraints(mandatoryConstraints: [audioConstraint, videoConstraint], optionalConstraints: [ dtlsConstraint]) RTCPeerConnectionFactory.initializeSSL() peerConnection = peerConnectionFactory.peerConnectionWithICEServers(servers, constraints: mediaContraints, delegate: self) dataChannels = peerConnection?.createDataChannelWithLabel(channelName,config: nil) dataChannels?.delegate = self var message : NSData = NSData(base64EncodedString: "helloo") var buffer : RTCDataBuffer = RTCDataBuffer(data: message, isBinary: true) dataChannels?.sendData(buffer) 

你解决了吗? 两个对等体之一应该创build数据通道,其他的应该将接收到的数据通道对象附加到其数据通道对象。 发起者应该在发送offer之前创builddatachannel。 希望这可能会有所帮助

我有同样的问题,直到我设置选项不为零。 如果我跳过蒸气,它不会发送。 即使频道是开放的。

 RTCDataChannelInit *dataInit = [[RTCDataChannelInit alloc] init]; dataInit.isNegotiated = YES; dataInit.isOrdered = YES; dataInit.maxRetransmits = 30; dataInit.maxRetransmitTimeMs = 30000; dataInit.streamId = 12; //important setting self.dataChannel = [_peerConnection createDataChannelWithLabel:kRTCDataChannelLabel config:dataInit]; self.dataChannel.delegate = self;