Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daviddias/webrtc-connect
Establish WebRTC Data Channels between browser-node and node-node with a TCP/HTTP/WebSockets "createServer/attach" like interface
https://github.com/daviddias/webrtc-connect
Last synced: 4 minutes ago
JSON representation
Establish WebRTC Data Channels between browser-node and node-node with a TCP/HTTP/WebSockets "createServer/attach" like interface
- Host: GitHub
- URL: https://github.com/daviddias/webrtc-connect
- Owner: daviddias
- License: mit
- Created: 2015-05-27T00:01:52.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-09T04:54:23.000Z (almost 9 years ago)
- Last Synced: 2024-05-22T18:15:38.365Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 8.65 MB
- Stars: 17
- Watchers: 0
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-peer-to-peer - webrtc-connect - node and node-node with a TCP/HTTP/WebSockets "createServer/attach" like interface (Modules)
README
webrtc-connect
==============> Establish WebRTC Data Channels between browser-node and node-node with a TCP/HTTP/WebSockets "createServer/attach" like interface
# Badgers
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)# Why no use WebSockets instead?
WebRTC provides a set of different features, one of them being confidentiality, that is, [WebRTC Data Channels are encrypted by default][1] and can't be eavesdropped, while for WebSockets, [we need first to set up TLS/SSL][2].
When it comes to implement authenticity, make sure to reference to ["WebRTC and MITM Attacks" article from on WebRTC Hacks](https://webrtchacks.com/webrtc-and-man-in-the-middle-attacks), as it offers a very good insight.
# Usage
### Client
Works in node.js and in the browser(one that supports WebRTC that is :))
with browserify or by including the standalone file `webrtc-connect.min.js` which exports a `rtcc` object to window.```javascript
var rtcc = require('webrtc-connect');rtcc.connect({url: 'http://localhost', port: 9999}, function(err, channel) {
if (err)
return console.log('err', err);
channel.send('hey! how are you?');
channel.on('data', function(data){
console.log('received message - ', data);
});
});
```### Server
Boot a fresh http server to establish the connection:
```javascript
var rtcc = require('webrtc-connect');rtcc.createServer(function(err, channel){
if (err)
return console.log('err', err);
channel.on('data', function(data){
console.log('received message - ', data);
channel.send('good and you?');
});}).listen('9999');
```Attach to an existing http server of your app:
```javascript
var rtcc = require('webrtc-connect');rtcc.createServer(function(err, channel){
if (err)
return console.log('err', err);
channel.on('data', function(data){
console.log('received message - ', data);
channel.send('good and you?');
});}).attach(EXISTING_HTTP_SERVER);
```[1]: http://sporadicdispatches.blogspot.pt/2013/06/webrtc-security-and-confidentiality.html
[2]: https://msdn.microsoft.com/en-us/library/windows/apps/hh761446.aspx