mirror of https://github.com/BTCPrivate/copay.git
clean config for peerjs
This commit is contained in:
parent
b79aefefee
commit
f9ee67b548
10
js/config.js
10
js/config.js
|
@ -3,12 +3,12 @@
|
||||||
var config = {
|
var config = {
|
||||||
networkName: 'testnet',
|
networkName: 'testnet',
|
||||||
network: {
|
network: {
|
||||||
// apiKey: 'lwjd5qra8257b9',
|
key: 'lwjd5qra8257b9',
|
||||||
// This is for running local peerJs with params: ./peerjs -p 10009 -k 'sdfjhwefh'
|
// This is for running local peerJs with params: ./peerjs -p 10009 -k 'sdfjhwefh'
|
||||||
apiKey: 'sdfjhwefh',
|
// key: 'sdfjhwefh',
|
||||||
host: 'localhost',
|
// host: 'localhost',
|
||||||
port: 10009,
|
// port: 10009,
|
||||||
path: '/',
|
// path: '/',
|
||||||
maxPeers: 3,
|
maxPeers: 3,
|
||||||
debug: 3,
|
debug: 3,
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,17 +16,18 @@ var EventEmitter= imports.EventEmitter || require('events').EventEmitter;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function Network(opts) {
|
function Network(opts) {
|
||||||
|
var self = this;
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
this.peerId = opts.peerId;
|
this.peerId = opts.peerId;
|
||||||
this.apiKey = opts.apiKey || 'lwjd5qra8257b9';
|
this.apiKey = opts.apiKey || 'lwjd5qra8257b9';
|
||||||
this.debug = opts.debug || 3;
|
this.debug = opts.debug || 3;
|
||||||
this.maxPeers = opts.maxPeers || 5;
|
this.maxPeers = opts.maxPeers || 5;
|
||||||
|
this.opts = { key: opts.key };
|
||||||
|
|
||||||
// For using your own peerJs server
|
// For using your own peerJs server
|
||||||
this.port = opts.port;
|
['port', 'host', 'path', 'debug'].forEach(function(k) {
|
||||||
this.host = opts.host;
|
if (opts[k]) self.opts[k]=opts[k];
|
||||||
this.path = opts.path;
|
});
|
||||||
|
|
||||||
this.connectedPeers = [];
|
this.connectedPeers = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,14 +219,7 @@ Network.prototype.start = function(openCallback) {
|
||||||
// Start PeerJS Peer
|
// Start PeerJS Peer
|
||||||
if (this.peer) return openCallback(); // This is for connectTo-> peer is started before
|
if (this.peer) return openCallback(); // This is for connectTo-> peer is started before
|
||||||
|
|
||||||
this.peer = new Peer(this.peerId, {
|
this.peer = new Peer(this.peerId, this.opts);
|
||||||
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._setupPeerHandlers(openCallback);
|
this._setupPeerHandlers(openCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue