From 4f359c05cadc3261e1a1357fc67341e9848e6084 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 7 Aug 2014 18:10:02 -0300 Subject: [PATCH] basic stuff working --- config.js | 73 ++++---------------------------------- js/models/network/Async.js | 11 +++--- 2 files changed, 11 insertions(+), 73 deletions(-) diff --git a/config.js b/config.js index 4da6227cc..73293528c 100644 --- a/config.js +++ b/config.js @@ -1,7 +1,7 @@ 'use strict'; var defaultConfig = { // DEFAULT network (livenet or testnet) - networkName: 'livenet', + networkName: 'testnet', forceNetwork: false, // DEFAULT unit: Bit @@ -15,71 +15,10 @@ var defaultConfig = { minAmountSatoshi: 5400, }, - // network layer (PeerJS) config + // network layer config network: { - // Use this to run your own local PeerJS server - // with params: ./peerjs -p 10009 -k '6d6d751ea61e26f2' - /* -key: '6d6d751ea61e26f2', -host: 'localhost', -port: 10009, -path: '/', -*/ - - // Use this to connect to bitpay's PeerJS server - key: 'satoshirocks', - // host: '162.242.219.26', - // port: 10000, - // secure: false, - host: 'live.copay.io', - port: 9000, - secure: true, - path: '/', - - // other PeerJS config - maxPeers: 15, - debug: 2, - - // PeerJS internal config object - config: { - 'iceServers': [ - // Pass in STUN and TURN servers for maximum network compatibility - { - url: 'stun:162.242.219.26' - }, { - url: 'turn:162.242.219.26', - username: 'bitcore', - credential: 'bitcore', - } - // { - // url: 'stun:stun.l.google.com:19302' - // }, { - // url: 'stun:stun1.l.google.com:19302' - // }, { - // url: 'stun:stun2.l.google.com:19302' - // }, { - // url: 'stun:stun3.l.google.com:19302' - // }, { - // url: 'stun:stun4.l.google.com:19302' - // }, { - // url: 'stun:stunserver.org' - // } - // // Options fot TURN servers with p2p communications are not possible. - // { - // url: 'turn:numb.viagenie.ca', - // credential: 'muazkh', - // username: 'webrtc@live.com' - // }, { - // url: 'turn:192.158.29.39:3478?transport=udp', - // credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=', - // username: '28224511:1379330808' - // }, { - // url: 'turn:192.158.29.39:3478?transport=tcp', - // credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=', - // username: '28224511:1379330808' - // } - ] - } + host: 'localhost', + port: 3001 }, // wallet default config @@ -96,14 +35,14 @@ path: '/', // blockchain service API config blockchain: { schema: 'https', - host: 'insight.bitpay.com', + host: 'test-insight.bitpay.com', port: 443, retryDelay: 1000, }, // socket service API config socket: { schema: 'https', - host: 'insight.bitpay.com', + host: 'test-insight.bitpay.com', port: 443, reconnectDelay: 1000, }, diff --git a/js/models/network/Async.js b/js/models/network/Async.js index 9d17c621f..1558abddc 100644 --- a/js/models/network/Async.js +++ b/js/models/network/Async.js @@ -240,16 +240,14 @@ Network.prototype._checkAnyPeer = function(msg) { } }; -Network.prototype._setupConnectionHandlers = function(toCopayerId) { +Network.prototype._setupConnectionHandlers = function() { preconditions.checkState(this.socket); var self = this; - var isInbound = toCopayerId ? false : true; - self.socket.on('connect', function() { - console.log('CONNECTED!'); + alert('CONNECTED!'); self.socket.on('disconnect', function() { - console.log('DISCONNECTED'); + alert('DISCONNECTED'); self.cleanUp(); }); }); @@ -297,6 +295,7 @@ Network.prototype.peerFromCopayer = function(hex) { }; Network.prototype.start = function(opts, openCallback) { + alert('start'); opts = opts || {}; if (this.started) return openCallback(); @@ -324,7 +323,7 @@ Network.prototype.start = function(opts, openCallback) { this.socket.emit('subscribe', this.getKey().public.toString('hex')); this.socket.emit('sync'); this.started = true; - this._setupConnectionHandlers(this.socket); + this._setupConnectionHandlers(); //this.emit('serverError', self.criticalError);