[英]How to use WebRTC APIs in Node.js without browser or any HTML?
So i'm making a command line application which will send text messages between two clients using WebRTC and Node.js with socket.io signalling.所以我正在制作一个命令行应用程序,它将使用 WebRTC 和 Node.js 和 socket.io 信号在两个客户端之间发送文本消息。 But when i'm using the RTCPeerConnection api there is this error:
但是当我使用 RTCPeerConnection api 有这个错误:
myConnection = new RTCPeerConnection(configuration, {
^
ReferenceError: RTCPeerConnection is not defined
The code segment is:代码段是:
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
});
}
};
But when I include this js file in an HTML file as a script then it works fine.但是,当我将此 js 文件作为脚本包含在 HTML 文件中时,它可以正常工作。 Does it have something to with the fact that WebRTC is a browser API and doesn't work outside it?
这是否与 WebRTC 是浏览器 API 并且在它之外不起作用这一事实有关? I really don't wanna use a library for WebRTC.
我真的不想为 WebRTC 使用库。 What should I do to make use of WebRTC apis without a browser?
在没有浏览器的情况下如何使用 WebRTC apis?
It is mandatory to use a library for WebRTC in node.必须在节点中使用 WebRTC 库。 Why do you not want to use wrtc ?
为什么你不想使用wrtc ? It is the same exact API as the browser.
它与浏览器完全相同的 API。
If you are willing to use other languages you could also do C/C++, Go or Python.如果您愿意使用其他语言,您也可以使用 C/C++、Go 或 Python。 I don't know of bindings in other languages.
我不知道其他语言的绑定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.