getting to intermediate screen!

This commit is contained in:
Manuel Araoz 2014-08-07 20:15:55 -03:00
commit bfd4bbe021
2 changed files with 12 additions and 5 deletions

View file

@ -451,10 +451,12 @@ Wallet.prototype.netStart = function(callback) {
} }
net.start(startOpts, function() { net.start(startOpts, function() {
alert('start callback!');
self.emit('ready', net.getPeer()); self.emit('ready', net.getPeer());
setTimeout(function() { setTimeout(function() {
self.emit('publicKeyRingUpdated', true); self.emit('publicKeyRingUpdated', true);
self.scheduleConnect(); //self.scheduleConnect();
// no connection logic for now
self.emit('txProposalsUpdated'); self.emit('txProposalsUpdated');
}, 10); }, 10);
}); });

View file

@ -234,7 +234,7 @@ Network.prototype._onMessage = function(enc) {
} }
}; };
Network.prototype._setupConnectionHandlers = function() { Network.prototype._setupConnectionHandlers = function(cb) {
preconditions.checkState(this.socket); preconditions.checkState(this.socket);
var self = this; var self = this;
@ -244,6 +244,7 @@ Network.prototype._setupConnectionHandlers = function() {
alert('DISCONNECTED'); alert('DISCONNECTED');
self.cleanUp(); self.cleanUp();
}); });
if (typeof cb === 'function') cb();
}); });
self.socket.on('message', self._onMessage); self.socket.on('message', self._onMessage);
self.socket.on('error', self._handleError); self.socket.on('error', self._handleError);
@ -300,7 +301,10 @@ Network.prototype.start = function(opts, openCallback) {
if (!this.copayerId) if (!this.copayerId)
this.setCopayerId(opts.copayerId); this.setCopayerId(opts.copayerId);
if (this.connectedPeers.length > 0) return; // Already connected! if (this.connectedPeers.length > 0) {
// already connected
return;
}
if (this.socket) { if (this.socket) {
this.socket.destroy(); this.socket.destroy();
this.socket.removeAllListeners(); this.socket.removeAllListeners();
@ -309,10 +313,11 @@ Network.prototype.start = function(opts, openCallback) {
this.socket = io.connect(this.host + ':' + this.port, { this.socket = io.connect(this.host + ':' + this.port, {
//reconnection: false, //reconnection: false,
}); });
this.socket.emit('subscribe', this.getKey().public.toString('hex')); this._setupConnectionHandlers(openCallback);
var pubkey = this.getKey().public.toString('hex');
this.socket.emit('subscribe', pubkey);
this.socket.emit('sync'); this.socket.emit('sync');
this.started = true; this.started = true;
this._setupConnectionHandlers();
//this.emit('serverError', self.criticalError); //this.emit('serverError', self.criticalError);