Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
webrtc-conductor
Advanced tools
A lightweight module to allow for efficient management, creation, reuse and destruction of WebRTC DataChannels.
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.
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.
}
);
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.
Note: Breaking changes will regularly occur before v1.0.0 due to instability of the library. Use at your own risk!
FAQs
A lightweight module to allow for efficient management, creation, reuse and destruction of WebRTC DataChannels.
The npm package webrtc-conductor receives a total of 3,270 weekly downloads. As such, webrtc-conductor popularity was classified as popular.
We found that webrtc-conductor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.