mirror of https://github.com/BTCPrivate/copay.git
add subscribed event
This commit is contained in:
parent
2c354525ea
commit
02b8ceb35e
|
@ -290,25 +290,12 @@ Network.prototype.start = function(opts, openCallback) {
|
||||||
this._setupConnectionHandlers(openCallback);
|
this._setupConnectionHandlers(openCallback);
|
||||||
this.socket.emit('subscribe', pubkey);
|
this.socket.emit('subscribe', pubkey);
|
||||||
|
|
||||||
|
|
||||||
var fromTs = opts.lastTimestamp + 1;
|
var fromTs = opts.lastTimestamp + 1;
|
||||||
var self = this,
|
var self = this;
|
||||||
tries = 0;
|
self.socket.on('subscribed', function(m) {
|
||||||
self.socket.on('insight-error', function(m) {
|
|
||||||
|
|
||||||
console.log('Retrying to sync...');
|
|
||||||
setTimeout(function() {
|
|
||||||
if (tries++ > 5) {
|
|
||||||
self.emit('serverError');
|
|
||||||
} else {
|
|
||||||
self.socket.emit('sync', fromTs);
|
|
||||||
}
|
|
||||||
}, 500);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
self.socket.emit('sync', fromTs);
|
self.socket.emit('sync', fromTs);
|
||||||
self.started = true;
|
self.started = true;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.prototype.createSocket = function() {
|
Network.prototype.createSocket = function() {
|
||||||
|
@ -356,7 +343,7 @@ Network.prototype.send = function(dest, payload, cb) {
|
||||||
|
|
||||||
var l = dest.length;
|
var l = dest.length;
|
||||||
var i = 0;
|
var i = 0;
|
||||||
for(var ii in dest){
|
for (var ii in dest) {
|
||||||
var to = dest[ii];
|
var to = dest[ii];
|
||||||
if (to == this.copayerId)
|
if (to == this.copayerId)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue