我正在制作一个命令行应用程序,它将使用WebRTC和Node.js与socket.io信号在两个客户端之间发送文本信息。但当我使用RTCPeerConnection api时,出现了这个错误。
myConnection = new RTCPeerConnection(configuration, {
ReferenceError: RTCPeerConnection is not defined
代码段是 。
var configuration = {
"iceServers": [{ "url": "stun:stun.1.google.com:19302" }]
myConnection = new RTCPeerConnection(configuration, {
optional: [{RtpDataChannels: true}]
console.log("RTCPeerConnection object was created");
console.log(myConnection);
//setup ice handling
//when the browser finds an ice candidate we send it to another peer
myConnection.onicecandidate = function (event) {
console.log("Ice candidates found");
if (event.candidate) {
send({
type: "candidate",
candidate: event.candidate