使用WebRTC使node.js应用程序成为PEER [英] Making a node.js application a PEER with WebRTC

查看:114
本文介绍了使用WebRTC使node.js应用程序成为PEER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有一个Web应用程序,它生成大量的颜色信息缓冲区,我想发送给在本地网络中另一台机器上运行的节点应用程序。 Web套接字对我来说似乎不够快。我当时希望使用UDP,似乎WebRTC是从浏览器中实现这一目标的唯一方法。值得注意的是,WebRTC只是PEER到PEER(浏览器到浏览器)。我想,我可以使用node webkit来模仿我的另一个PEER。在我的节点应用程序中,我可以处理信令并让它自己设置在我的网络应用程序的RTCPeerConnection中。因此,我可以将我的数据从我的网络应用程序发送到我的节点应用程序(本地网络)。在某些情况下,我有一台计算机运行本机软件来驱动灯具,我想使用网络应用来控制灯光。

So, I have a web app that generates large buffers of color information that I want to send to a node application running on another machine in my local network. Web Sockets doesn't seem to be fast enough for me. I was looking to use UDP and it seems WebRTC is the only way to do that from a browser. The caveat, it seems, is WebRTC is only PEER to PEER (browser to browser). I figured, I could use node webkit to emulate being my other "PEER". In my node app I could handle the "signaling" and have it set itself up in a RTCPeerConnection to my web app. Therefore, I could send my data from my web app to my node app (local network). For some context, I have one computer running native software to drive a light fixture and I want to use a web app to control the lights.

将问题烧掉,如何从浏览器到节点webkit应用程序进行RTCPeerConnection?

To boil the question down, how can I make a RTCPeerConnection from a browser to a node webkit app?

任何帮助都会非常感谢。

Any help would greatly appreciated.

谢谢!

-Jake

推荐答案

Node-RTCPeerConnection 是一种尝试(当前WIP )来创建完全在JavaScript中的Node.js的RTCPeerConnection的规范兼容实现,没有本机C或C ++代码。这使得浏览器对等体可以与非浏览器(Node.js)对等体通话。

Node-RTCPeerConnection is an attempt (current WIP) to create a spec compliant implementation of RTCPeerConnection for Node.js entirely in JavaScript with no native C or C++ code. This enables browser-peers to speak to non-browser (Node.js) peers.

但是你还不能将它用于生产。

But you can not use it for production yet.

然后我们还有 wrtc (node-webrtc)为NodeJS提供本机模块,支持符合标准的WebRTC功能的子集。具体来说,PeerConnection和DataChannel API。

Then we also have wrtc (node-webrtc) that provides a native module for NodeJS that supports a subset of standards-compliant WebRTC features. Specifically, the PeerConnection and DataChannel APIs.

太多人遇到 wrtc 的问题。因为它必须下载大量的源代码并构建它只是为了发现它在某些平台上很长一段时间后才会失败。不幸的是,它没有附带任何预先构建的软件包在此问题中描述

Too many people are having problems with wrtc. Since it has to download lots of source and build it only to find out that it fails after a long while on certain platforms. Unfortunately it doesn't come with any prebuilt packages described in this issue

您可以使用 google实施webrtc 或更近期的实施(爱立信),名为 openWebrtc 。 openWebRTC的开发人员非常自豪能够在各种硬件上运行他们的实现,如raspberry pi和iOS设备。

You can use either the google implementation of webrtc or a more recent implementation (by Ericsson) called openWebrtc. The developers of openWebRTC are very proud of running their implementation on various pieces of hardware like raspberry pi and iOS devices.

最适合我的是 electron-webrtc (反过来使用电子预建)以获得更好的兼容性。它创建了一个隐藏的Electron流程(基于Chromium,因此WebRTC支持很棒!)并与该流程通信以在Node.js中启用WebRTC。这会增加很多开销。

The one that worked best for me was electron-webrtc (which in turn uses electron-prebuilt) for better compatibility. It creates a hidden Electron process (which is based on Chromium, so WebRTC support is great!) and communicates with that process to enable WebRTC in Node.js. This adds a lot of overhead.

它适用于RTCDataChannels,因此不支持MediaStream API。

It is intended for use with RTCDataChannels, so the MediaStream API is not supported.

其他资源:

https://github.com/webrtcftw/goals/issues/1

这篇关于使用WebRTC使node.js应用程序成为PEER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆