我想用RTCPeerConnections连接两个对等节点,但无法将IceCandidate从Alice添加到Bob。
例:
var alice = new RtcPeerConnection(
{"iceServers": [{"url": "stun:stun.l.google.com:19302"}]}
);
var bob = new RtcPeerConnection(
{"iceServers": [{"url": "stun:stun.l.google.com:19302"}]}
);
alice.createDataChannel("somelablel", {});
alice.onNegotiationNeeded.listen((var data){
alice.createOffer({}).then((var offer){
//got offer
alice.setLocalDescription(offer);
bob.setRemoteDescription(offer);
});
});
bob.onIceCandidate.listen((evt) {
if (evt.candidate)
print(evt.cancelable);
});
alice.onIceCandidate.listen((evt) {
if(evt.candidate != null)
//TODO: add iceCandidate to Bob
});
第一版(似乎很旧,但在在线示例中大量使用):
bob.addIceCandidate(candidatefromAlice);
输出:
Class 'RtcPeerConnection' has no instance method
'addIceCandidate' with matching arguments.
第二次尝试(具有3个参数的新版本):
bob.addIceCandidate(candidatefromAlice, (){}, (var error){
print(error.toString());
});
输出:
NotSupportedError: The implementation did not support the
requested type of object or operation. (Dartium)
如何在没有问题的情况下将ICE候选人设置为 Dart ?
信息:
最佳答案
我认为您必须等到修复此错误后,
https://code.google.com/p/dart/issues/detail?id=15008
您要求的代码似乎是
bob.addIceCandidate(evt.candidate, () => print('void: $evt'), (var x) => print('FailureCallback: $evt'));
对这个问题的评论Is addIceCandidate implemented in Dartium?似乎表明它在Dartium中不起作用,但在将项目转换为JavaScript后在Chrome中可以工作。