basic stuff working

This commit is contained in:
Manuel Araoz 2014-08-07 18:10:02 -03:00
parent 48dd8549ef
commit 4f359c05ca
2 changed files with 11 additions and 73 deletions

View File

@ -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,
},

View File

@ -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);