Add transaction-inbound and transaction-outbound events

This commit is contained in:
wltsmrz
2013-08-21 16:41:01 -07:00
parent ba48078f9e
commit ccd1758284

View File

@@ -162,23 +162,21 @@ Account.prototype.get_next_sequence = function(callback) {
*
* @param {function (err, lines)} callback Called with the result
*/
Account.prototype.lines = function (callback)
{
Account.prototype.lines = function (callback) {
var self = this;
var callback = typeof callback === 'function' ? callback : function(){};
self._remote.request_account_lines(this._account_id)
.on('success', function (e) {
function account_lines(err, lines) {
if (err) {
callback(err);
} else {
self._lines = e.lines;
self.emit('lines', self._lines);
callback(null, e);
}
}
if ("function" === typeof callback) {
callback(null, e);
}
})
.on('error', function (e) {
callback(e);
})
.request();
this._remote.request_account_lines(this._account_id, account_lines);
return this;
};
@@ -195,6 +193,14 @@ Account.prototype.notifyTx = function (message) {
// occurring.
if (this._subs) {
this.emit('transaction', message);
try {
var account = message.transaction.Account;
} catch(exception) { }
if (account === this._account_id) {
this.emit('transaction-outbound');
} else {
this.emit('transaction-inbound');
}
}
};