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(
|
||||
argv.url
|
||||
|| process.env.BCOIN_URL
|
||||
|| 'localhost:' + network.rpcPort
|
||||
|| 'http://localhost:' + network.rpcPort
|
||||
);
|
||||
|
||||
client.on('error', function(err) {
|
||||
bcoin.error(err);
|
||||
});
|
||||
|
||||
function getID() {
|
||||
if (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) {
|
||||
var id = getID();
|
||||
client.getWalletBalance(id, function(err, balance) {
|
||||
@ -244,6 +273,8 @@ function main(callback) {
|
||||
switch (argv.args.shift()) {
|
||||
case 'wallet':
|
||||
return createWallet(callback);
|
||||
case 'listen':
|
||||
return listenWallet(callback);
|
||||
case 'getwallet':
|
||||
return getWallet(callback);
|
||||
case 'addkey':
|
||||
|
||||
@ -113,7 +113,7 @@ HTTPBase.prototype._initRouter = function _initRouter() {
|
||||
try {
|
||||
parsePath(req);
|
||||
} catch (e) {
|
||||
done(e);
|
||||
return done(e);
|
||||
}
|
||||
|
||||
self.emit('request', req, res);
|
||||
|
||||
@ -60,7 +60,7 @@ HTTPClient.prototype._init = function _init() {
|
||||
self.emit('error', err);
|
||||
});
|
||||
|
||||
this.socket.on('open', function() {
|
||||
this.socket.on('connect', function() {
|
||||
self.socket.on('version', function(info) {
|
||||
bcoin.debug('Connected to bcoin server: %s (%s)',
|
||||
info.version, info.network);
|
||||
|
||||
@ -39,7 +39,6 @@ function HTTPServer(options) {
|
||||
this.loaded = false;
|
||||
|
||||
this.server = new HTTPBase(options);
|
||||
this.io = null;
|
||||
|
||||
this._init();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user