Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webrtc-conductor

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webrtc-conductor

A lightweight module to allow for efficient management, creation, reuse and destruction of WebRTC DataChannels.

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.3K
increased by50.76%
Maintainers
1
Weekly downloads
 
Created
Source

WebRTC Conductor Build Status Code Climate

A lightweight ES6 module to allow for efficient and simple management, creation, reuse and destruction of WebRTC DataChannels - independent of the signalling channel used for negotiation.

Presently, the module is extremely unstable and is functional up to the point where I can use it with a small amount of difficulty in my projects. Over time, I will fix and extend this module as needed.

Overview

One of the main goals of this library is to decouple the signalling channel used to initialise WebRTC connections from the management library itself - a move that I'm surprised no other library appears to have taken.

To connect to another peer:

//Assuming the existence of a channel implementation, FooChannel(webSocketAddr){...}
var Conductor = require("webrtc-conductor");

var myConductor = Conductor.create({
  channel: new FooChannel("ws://somesite.com:9999")
});

myConductor.onconnection = /* Function handling connections made to this system. */;
 
myConductor.connectTo(/* String containing your partner's id. */)
  .then(
    result => {
      //Code handling the connection.
    }, reason => {
      //Code handling a failed connection attempt.
    }
  );

Channels

Although these are properly detailed in src/example_channels/structure_example.js, a rough description is as follows:

function FooChannel(param){
	// A reference to the bound manager.
	// You may call:
	//	_manager.response(msg, channel):			alert the manager that a response 
	//												has been received, and delegate
	//												parsing it to the given channel.
	//
	//	_manager.renameConnection(name1, name2):	inform the manager that it must
	//												change a channel's name - typically
	//												used for bootstrapping into a
	//												P2P network.
	this._manager = null;

	// Internal ID used by the registry of the manager to help find
	// registered channels by name.
	this.internalID = "structure_example";

	// Function called by manager when opening a new WebRTC Data Channel. This function
	// is used to convert webrtc negotiation details into a form suitable for the
	// channel, as well as sending this information along the channel.
	this.send = function(id, type, data){
		/*...*/
	};

	// Function called by the manager if the _manager.response(msg, channel)
	// method is called. This function is used to parse and handle the data
	// actually received, and interpret what class of message has been received.
	this.onmessage = function(msg){
		/*...*/
	};

	// An optional function called by the manager once the channel has been bound to it.
	this.onbind = function(){
		/*...*/
	};

	// Function called by the manager or application code if the channel must be closed.
	// All cleanup and related logic should be handled here so that open connections
	// are not left inaccessible by the program.
	this.close = function(){
		/* ... */
	};
}

If you are implementing your own channel, I strongly recommend referring to the specification document to be aware of expected return types, further conventions and so on.

Changelog

Note: Breaking changes will regularly occur before v1.0.0 due to instability of the library. Use at your own risk!

0.1.3

  • Addition of simple .close() method on connections. This closes a connection for real, and is not intelligently managed.

0.1.2

  • Change of dependencies to get webrtc-adapter-test from the official git now that API changes have been merged.

0.1.1

  • Removal of wrtc as an optional dependency.

0.1.0

  • Addition of .renameConnection() method for channels to use in cases where the destination is not yet known.
  • Addition of .onconnection property, called when a channel is opened to the current user from another source.

0.0.1

  • Initial Implementation

Keywords

FAQs

Package last updated on 22 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc