Skip to content

Commit

Permalink
feat(*): add peerjs factory implementation that works in nodejs πŸŽ‰
Browse files Browse the repository at this point in the history
cobble together hack found here: peers/peerjs#103 (comment)
and here: peers/peerjs#103 (comment) to get peerjs working in
a node app

peers/peerjs#103
  • Loading branch information
web-mech committed Jan 19, 2018
1 parent ee181da commit d964fe3
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions index.js
@@ -0,0 +1,32 @@
window = global;
window.BlobBuilder = require('BlobBuilder');

BinaryPack = require('binary-pack')
XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
var wrtc = require('electron-webrtc')()


RTCPeerConnection = wrtc.RTCPeerConnection;
RTCSessionDescription = wrtc.RTCSessionDescription;
RTCIceCandidate = wrtc.RTCIceCandidate;


WebSocket = require('ws');
location = {
protocol: 'http'
};

require('peerjs/lib/exports');

module.exports = function(id, options) {
// Deal with overloading :-D
if (id && id.constructor == Object) {
options = id;
id = undefined;
} else if (id) {
// Ensure id is a string
id = id.toString();
}

return new Peer(id, options);
};

0 comments on commit d964fe3

Please sign in to comment.