mirror of https://github.com/BTCPrivate/copay.git
handle no-messages
This commit is contained in:
parent
534a5f6349
commit
9888bc9448
|
@ -310,6 +310,12 @@ Wallet.prototype.updateTimestamp = function(ts) {
|
||||||
this.store();
|
this.store();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Wallet.prototype._onNoMessages = function() {
|
||||||
|
console.log('No messages at the server. Requesting sync'); //TODO
|
||||||
|
this.sendWalletReady(senderId);
|
||||||
|
};
|
||||||
|
|
||||||
Wallet.prototype._onData = function(senderId, data, ts) {
|
Wallet.prototype._onData = function(senderId, data, ts) {
|
||||||
preconditions.checkArgument(senderId);
|
preconditions.checkArgument(senderId);
|
||||||
preconditions.checkArgument(data);
|
preconditions.checkArgument(data);
|
||||||
|
@ -355,9 +361,10 @@ Wallet.prototype._onData = function(senderId, data, ts) {
|
||||||
case 'disconnect':
|
case 'disconnect':
|
||||||
this._onDisconnect(senderId, data);
|
this._onDisconnect(senderId, data);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error('unknown message type received: '+ data.type + ' from: ' + senderId)
|
||||||
}
|
}
|
||||||
this.updateTimestamp(ts);
|
this.updateTimestamp(ts);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype._onConnect = function(newCopayerId) {
|
Wallet.prototype._onConnect = function(newCopayerId) {
|
||||||
|
@ -433,6 +440,7 @@ Wallet.prototype.netStart = function(callback) {
|
||||||
net.removeAllListeners();
|
net.removeAllListeners();
|
||||||
net.on('connect', self._onConnect.bind(self));
|
net.on('connect', self._onConnect.bind(self));
|
||||||
net.on('data', self._onData.bind(self));
|
net.on('data', self._onData.bind(self));
|
||||||
|
net.on('no messages', self._onNoMessages.bind(self));
|
||||||
|
|
||||||
var myId = self.getMyCopayerId();
|
var myId = self.getMyCopayerId();
|
||||||
var myIdPriv = self.getMyCopayerIdPriv();
|
var myIdPriv = self.getMyCopayerIdPriv();
|
||||||
|
|
|
@ -220,6 +220,8 @@ Network.prototype._setupConnectionHandlers = function(cb) {
|
||||||
});
|
});
|
||||||
self.socket.on('error', self._onError.bind(self));
|
self.socket.on('error', self._onError.bind(self));
|
||||||
|
|
||||||
|
self.socket.on('no messages', self.bind(self, 'no messages'));
|
||||||
|
|
||||||
self.socket.on('connect', function() {
|
self.socket.on('connect', function() {
|
||||||
|
|
||||||
self.socket.on('disconnect', function() {
|
self.socket.on('disconnect', function() {
|
||||||
|
@ -302,6 +304,7 @@ Network.prototype.start = function(opts, openCallback) {
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
self.socket.emit('sync', opts.lastTimestamp);
|
self.socket.emit('sync', opts.lastTimestamp);
|
||||||
self.started = true;
|
self.started = true;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue