mirror of https://github.com/BTCPrivate/copay.git
add polling as default transport in socket.io
This commit is contained in:
parent
ac491d10b0
commit
a70fd64442
|
@ -15,10 +15,12 @@ var defaultConfig = {
|
|||
// network layer config
|
||||
network: {
|
||||
testnet: {
|
||||
url: 'https://test-insight.bitpay.com:443'
|
||||
url: 'https://test-insight.bitpay.com:443',
|
||||
transports: ['polling'],
|
||||
},
|
||||
livenet: {
|
||||
url: 'https://insight.bitpay.com:443'
|
||||
url: 'https://insight.bitpay.com:443',
|
||||
transports: ['polling'],
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -18,6 +18,16 @@ function Network(opts) {
|
|||
this.url = opts.url;
|
||||
this.secretNumber = opts.secretNumber;
|
||||
this.cleanUp();
|
||||
|
||||
this.socketOptions = {
|
||||
reconnection: true,
|
||||
'force new connection': true,
|
||||
'secure': this.url.indexOf('https') === 0,
|
||||
};
|
||||
|
||||
if (opts.transports) {
|
||||
this.socketOptions['transports'] = opts.transports;
|
||||
}
|
||||
}
|
||||
|
||||
nodeUtil.inherits(Network, EventEmitter);
|
||||
|
@ -191,7 +201,7 @@ Network.prototype._onMessage = function(enc) {
|
|||
this._deletePeer(sender);
|
||||
return;
|
||||
}
|
||||
log.debug('receiving ' + JSON.stringify(payload));
|
||||
log.debug('Async: receiving ' + JSON.stringify(payload));
|
||||
|
||||
var self = this;
|
||||
switch (payload.type) {
|
||||
|
@ -254,6 +264,8 @@ Network.prototype._setupConnectionHandlers = function(opts, cb) {
|
|||
|
||||
self.socket.on('connect', function() {
|
||||
var pubkey = self.getKey().public.toString('hex');
|
||||
log.debug('Async subcribing to:pubkey:',pubkey);
|
||||
|
||||
self.socket.emit('subscribe', pubkey);
|
||||
|
||||
self.socket.on('disconnect', function() {
|
||||
|
@ -324,11 +336,9 @@ Network.prototype.start = function(opts, openCallback) {
|
|||
};
|
||||
|
||||
Network.prototype.createSocket = function() {
|
||||
return io.connect(this.url, {
|
||||
reconnection: true,
|
||||
'force new connection': true,
|
||||
'secure': this.url.indexOf('https') === 0,
|
||||
});
|
||||
|
||||
console.log('Async: Connecting to socket:', this.url, this.socketOptions); //TODO
|
||||
return io.connect(this.url, this.socketOptions);
|
||||
};
|
||||
|
||||
Network.prototype.getOnlinePeerIDs = function() {
|
||||
|
|
|
@ -42,6 +42,11 @@ var Insight = function(opts) {
|
|||
'secure': opts.url.indexOf('https') === 0
|
||||
};
|
||||
|
||||
|
||||
if (opts.transports) {
|
||||
this.opts['transports'] = opts.transports;
|
||||
}
|
||||
|
||||
this.socket = this.getSocket();
|
||||
}
|
||||
|
||||
|
|
|
@ -893,8 +893,9 @@ Wallet.prototype.netStart = function() {
|
|||
self.emit('connectionError');
|
||||
});
|
||||
|
||||
log.debug('Starting wallet networking');
|
||||
log.debug('Wallet: Starting networking');
|
||||
net.start(startOpts, function() {
|
||||
log.debug('Wallet: Networking ready');
|
||||
self._setBlockchainListeners();
|
||||
self.emit('ready', net.getPeer());
|
||||
setTimeout(function() {
|
||||
|
|
Loading…
Reference in New Issue