working towards refactoring network

This commit is contained in:
Manuel Araoz 2014-08-12 16:41:45 -04:00
commit 3ebacd50cc
5 changed files with 70 additions and 57 deletions

View file

@ -89,6 +89,7 @@ Wallet.prototype.seedCopayer = function(pubKey) {
this.seededCopayerId = pubKey;
};
// not being used now
Wallet.prototype.connectToAll = function() {
var all = this.publicKeyRing.getAllCopayerIds();
@ -317,7 +318,7 @@ Wallet.prototype._handleAddressBook = function(senderId, data, isInbound) {
Wallet.prototype._handleData = function(senderId, data, isInbound) {
// TODO check message signature
alert('data '+JSON.stringify(data));
if (data.type !== 'walletId' && this.id !== data.walletId) {
this.emit('badMessage', senderId);
@ -451,7 +452,6 @@ Wallet.prototype.netStart = function(callback) {
}
net.start(startOpts, function() {
alert('start callback!');
self.emit('ready', net.getPeer());
setTimeout(function() {
self.emit('publicKeyRingUpdated', true);
@ -462,6 +462,8 @@ Wallet.prototype.netStart = function(callback) {
});
};
// not being used now
Wallet.prototype.scheduleConnect = function() {
var self = this;
if (self.network.isOnline()) {

View file

@ -255,7 +255,7 @@ WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphras
});
self.network.start(opts, function() {
self.network.connectTo(s.pubKey);
self.network.greet(s.pubKey);
self.network.on('data', function(sender, data) {
if (data.type === 'walletId') {