diff --git a/js/config.js b/js/config.js index 2b3907516..cf2793f1f 100644 --- a/js/config.js +++ b/js/config.js @@ -3,12 +3,12 @@ var config = { networkName: 'testnet', network: { -// apiKey: 'lwjd5qra8257b9', + key: 'lwjd5qra8257b9', // This is for running local peerJs with params: ./peerjs -p 10009 -k 'sdfjhwefh' - apiKey: 'sdfjhwefh', - host: 'localhost', - port: 10009, - path: '/', + // key: 'sdfjhwefh', + // host: 'localhost', + // port: 10009, + // path: '/', maxPeers: 3, debug: 3, }, diff --git a/js/models/network/WebRTC.js b/js/models/network/WebRTC.js index c5c3de9bb..d1a16ae03 100644 --- a/js/models/network/WebRTC.js +++ b/js/models/network/WebRTC.js @@ -16,17 +16,18 @@ var EventEmitter= imports.EventEmitter || require('events').EventEmitter; */ function Network(opts) { + var self = this; opts = opts || {}; this.peerId = opts.peerId; this.apiKey = opts.apiKey || 'lwjd5qra8257b9'; this.debug = opts.debug || 3; this.maxPeers = opts.maxPeers || 5; + this.opts = { key: opts.key }; // For using your own peerJs server - this.port = opts.port; - this.host = opts.host; - this.path = opts.path; - + ['port', 'host', 'path', 'debug'].forEach(function(k) { + if (opts[k]) self.opts[k]=opts[k]; + }); this.connectedPeers = []; } @@ -218,14 +219,7 @@ Network.prototype.start = function(openCallback) { // Start PeerJS Peer if (this.peer) return openCallback(); // This is for connectTo-> peer is started before - this.peer = new Peer(this.peerId, { - key: this.apiKey, // TODO: we need our own PeerServer KEY (http://peerjs.com/peerserver) - host: this.host, - port: this.port, - path: this.path, - debug: this.debug, - }); - + this.peer = new Peer(this.peerId, this.opts); this._setupPeerHandlers(openCallback); };