socket.io fixes.
This commit is contained in:
parent
a1cabfb8bd
commit
ac21ebd151
@ -11,9 +11,13 @@ var Client = bcoin.http.client;
|
|||||||
var client = new Client(
|
var client = new Client(
|
||||||
argv.url
|
argv.url
|
||||||
|| process.env.BCOIN_URL
|
|| process.env.BCOIN_URL
|
||||||
|| 'localhost:' + network.rpcPort
|
|| 'http://localhost:' + network.rpcPort
|
||||||
);
|
);
|
||||||
|
|
||||||
|
client.on('error', function(err) {
|
||||||
|
bcoin.error(err);
|
||||||
|
});
|
||||||
|
|
||||||
function getID() {
|
function getID() {
|
||||||
if (argv.id)
|
if (argv.id)
|
||||||
return argv.id;
|
return argv.id;
|
||||||
@ -189,6 +193,31 @@ function getWalletHistory(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function listenWallet(callback) {
|
||||||
|
var id = getID();
|
||||||
|
client.listenWallet(id);
|
||||||
|
client.on('tx', function(tx, map) {
|
||||||
|
utils.print('TX:');
|
||||||
|
utils.print(tx);
|
||||||
|
utils.print(map);
|
||||||
|
});
|
||||||
|
client.on('updated', function(tx, map) {
|
||||||
|
utils.print('TX updated:');
|
||||||
|
utils.print(tx);
|
||||||
|
utils.print(map);
|
||||||
|
});
|
||||||
|
client.on('confirmed', function(tx, map) {
|
||||||
|
utils.print('TX updated:');
|
||||||
|
utils.print(tx);
|
||||||
|
utils.print(map);
|
||||||
|
});
|
||||||
|
client.on('balance', function(tx, map) {
|
||||||
|
utils.print('Balance:');
|
||||||
|
utils.print(tx);
|
||||||
|
utils.print(map);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function getBalance(callback) {
|
function getBalance(callback) {
|
||||||
var id = getID();
|
var id = getID();
|
||||||
client.getWalletBalance(id, function(err, balance) {
|
client.getWalletBalance(id, function(err, balance) {
|
||||||
@ -244,6 +273,8 @@ function main(callback) {
|
|||||||
switch (argv.args.shift()) {
|
switch (argv.args.shift()) {
|
||||||
case 'wallet':
|
case 'wallet':
|
||||||
return createWallet(callback);
|
return createWallet(callback);
|
||||||
|
case 'listen':
|
||||||
|
return listenWallet(callback);
|
||||||
case 'getwallet':
|
case 'getwallet':
|
||||||
return getWallet(callback);
|
return getWallet(callback);
|
||||||
case 'addkey':
|
case 'addkey':
|
||||||
|
|||||||
@ -113,7 +113,7 @@ HTTPBase.prototype._initRouter = function _initRouter() {
|
|||||||
try {
|
try {
|
||||||
parsePath(req);
|
parsePath(req);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
done(e);
|
return done(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.emit('request', req, res);
|
self.emit('request', req, res);
|
||||||
|
|||||||
@ -60,7 +60,7 @@ HTTPClient.prototype._init = function _init() {
|
|||||||
self.emit('error', err);
|
self.emit('error', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socket.on('open', function() {
|
this.socket.on('connect', function() {
|
||||||
self.socket.on('version', function(info) {
|
self.socket.on('version', function(info) {
|
||||||
bcoin.debug('Connected to bcoin server: %s (%s)',
|
bcoin.debug('Connected to bcoin server: %s (%s)',
|
||||||
info.version, info.network);
|
info.version, info.network);
|
||||||
|
|||||||
@ -39,7 +39,6 @@ function HTTPServer(options) {
|
|||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
|
|
||||||
this.server = new HTTPBase(options);
|
this.server = new HTTPBase(options);
|
||||||
this.io = null;
|
|
||||||
|
|
||||||
this._init();
|
this._init();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user