피어 연결이 이미 설정된 경우 데이터 채널을 만드는 방법이 있습니까? 여기peerConnection이 설정된 후 WebRTC 데이터 채널을 생성합니다.
내가 뭘하는지입니다 :
peerConnection.onstatechange = function(event){
var state = peerConnection.readyState;
console.log('state changed to : '+state);
if(state==='stable'){
console.log('connection is stable');
var dataChannel = peerConnection.createDataChannel('test',{reliable: false});
dataChannel.onopen = function(){
console.log('data channel opened');
dataChannel.send('hello data channel');
};
peerConnection.ondatachannel = function(event){
console.log('ondatachannel event fire ',event);
};
}
};
을 그리고 그것은 나에게 다음과 같은 출력을 제공합니다
state changed to : have-local-offer
state changed to : stable
connection is stable
- 어떻게 연결이 정말 설정되어 있는지 확인 할 수 있습니까?
stable
상태가active
인 동등 물인 here이 발견되었습니다. onopen
어떤 이유로 이벤트가 실행되지 않으므로 여전히 연결이 설정되어 있는지 확실하지 않습니다.
더 많은 코드가 필요하면 알려주세요.
는 편집 : 나는 onnegotiationneeded
이벤트 핸들러를 추가하고 지금 peerConnection.ondatachannel
이 발사되어 있지만 채널은 내가 가지고있는 당신은 같은 문제로 실행했을 수도
해결책을 얻었습니까? –
일종의,하지만 여전히 매우 불안정합니다. –