我正在开发两个对等方之间的信令系统,并注意到RTCPeerConnection.onicecandidate事件没有触发。 我检查了iceGatheringState并且它总是返回“new”,这意味着对等连接尚未开始搜索ice candidate。
我该如何从本地机器启动收集ice candidate对象以发送给对等方?
如果我不想滴漏candidates,那么一旦收集到它们,我如何通过sdp发送它们?
这是我的当前代码,我能够成功获取sdp数据并捕获它们以便发送,因此ice和检查两个客户端是否连接起来是唯一的问题。
我该如何从本地机器启动收集ice candidate对象以发送给对等方?
如果我不想滴漏candidates,那么一旦收集到它们,我如何通过sdp发送它们?
这是我的当前代码,我能够成功获取sdp数据并捕获它们以便发送,因此ice和检查两个客户端是否连接起来是唯一的问题。
var peerConn = new webkitRTCPeerConnection(
{'iceServers':[{'url':'stun:stun.1.google.com:19302'}]}
);
var remoteConn = new webkitRTCPeerConnection(
{'iceServers':[{'url':'stun:stun.1.google.com:19302'}]}
);
alert(peerConn.iceGatheringState);
///Event Handlers//
//will be called when each event occurs
//onicecandidate
//returns local ice candidates (when gathered) to be sent to peer
//peerConn.onicecandidate = onicecandidate;
peerConn.onicecandidate = function(iceEvent){ //not firing
if(iceEvent.candidate === null){
alert(peerConn.iceConnectionState);
alert(iceEvent.candidate);
//send to peer or put in with sdp data
}
}