我正在尝试将 webRTC 技术包含到我现有的 reactJs 应用程序中
问题是反应没有识别 webRTC API
Line 185:19: 'webkitRTCPeerConnection' is not defined no-undef
Line 191:1: 'rtcPeerConn' is not defined no-undef
Line 212:3: 'rtcPeerConn' is not defined no-undef
Line 214:62: 'rtcPeerConn' is not defined no-undef
此功能位于功能性反应组件内
function startSignaling(){
displayMessage("start signaling...");
rtcPeerConn = new webkitRTCPeerConnection(configuration)
//send ice candidate to other peer
rtcPeerConn.onicecandidate = function(evt){
if(evt.candidate){
io.emit("signal",{"type":"ice candidate","message":JSON.stringify({'candidate':evt.candidate}),room:signal_room})
displayMessage("completed that ice candidate");
}
}
rtcPeerConn.onnegotiationneeded = function(){
displayMessage("on negotiationnneded");
rtcPeerConn.createOffer(sendLocalDesc,logerror);
}
rtcPeerConn.onaddstream = (evt,err)=>{
displayMessage("creating the other stream");
if(err){
displayMessage(err)
}
success2(evt.stream);
}
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
navigator.mediaDevices.getUserMedia({video:true,audio:true}).then(stream=>{
success(stream);
// rtcPeerConn.addStream(stream);
}).catch(err=>{
logerror(err);
});
}