options for running with local peerJs server. Ux fixes

This commit is contained in:
Matias Alejo Garcia 2014-04-17 16:27:15 -03:00
commit 1e64031ec3
7 changed files with 85 additions and 31 deletions

View file

@ -96,8 +96,11 @@ Wallet.prototype._handleTxProposals = function(senderId, data, isInbound) {
Wallet.prototype._handleData = function(senderId, data, isInbound) {
if (this.id !== data.walletId)
throw new Error('wrong message received: Bad wallet ID');
if (this.id !== data.walletId) {
this.emit('badMessage',senderId);
this.log('badMessage FROM:', senderId); //TODO
return;
}
this.log('[Wallet.js.98]' , data.type); //TODO
@ -108,18 +111,16 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) {
case 'txProposals':
this._handleTxProposals(senderId, data, isInbound);
break;
case 'abort':
this.emit('abort');
break;
}
};
Wallet.prototype._handleNetworkChange = function(newPeer) {
if (!newPeer) return;
this.log('#### Setting new PEER:', newPeer);
this.sendWalletId(newPeer);
this.sendPublicKeyRing(newPeer);
this.sendTxProposals(newPeer);
if (newPeer) {
this.log('#### Setting new PEER:', newPeer);
this.sendWalletId(newPeer);
this.sendPublicKeyRing(newPeer);
this.sendTxProposals(newPeer);
}
this.emit('refresh');
};
@ -129,7 +130,13 @@ Wallet.prototype.netStart = function() {
net.on('networkChange', self._handleNetworkChange.bind(self) );
net.on('data', self._handleData.bind(self) );
net.on('open', function() {}); // TODO
net.on('close', function() {}); // TODO
net.on('openError', function() {
console.log('[Wallet.js.132:openError:] GOT openError'); //TODO
self.emit('openError');
});
net.on('close', function() {
self.emit('close');
});
net.start(function(peerId) {
self.emit('created');
});
@ -185,6 +192,7 @@ Wallet.prototype.sendPublicKeyRing = function(recipients) {
this.emit('publicKeyRingUpdated', this.publicKeyRing);
};
Wallet.prototype.generateAddress = function() {
var addr = this.publicKeyRing.generateAddress();
this.store();