Using WebRTC protocol in NodeJS with PubNub-WebRTC Package

While writing a series on how to control a web camera using an Arduino and WebRTC, I stumbled upon the need for a NodeJS implementation of WebRTC compatible with PubNub.

On my client I was using PubNub’s webrtc-sdk, so the path of least resistance was to take that same implementation and port it to work with NodeJS.

What I ended up with is the following package:

https://github.com/jeanlescure/node-pubnub-webrtc

It is available through NPM and using it in your NodeJS projects is as simple as installing:

$ npm install --save node-pubnub-webrtc

And implementing:

var phone = require('node-pubnub-webrtc')({
  number        : 'pubduino.server',
  publish_key   : PUBLISH_KEY,
  subscribe_key : SUBSCRIBE_KEY,
  ssl           : true
});

phone.receive(function(session){
  console.log('user connected');
});

phone.message(function(session, message){
  console.log('message received');
});

It should be noted that this implementation was built mainly to harness the RTCDataChannel, so if you’re looking to implement video and audio streams you’d need to find a way to shim the media streams to the PHONE object.

Happy coding!

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

©2017 KLEO Template a premium and multipurpose theme from Seventh Queen

Log in with your credentials

Forgot your details?