Add maxListeners config option

This commit is contained in:
Vinnie Falco
2013-05-01 16:16:50 -07:00
parent d1c1ac7fbb
commit 498e7df622

View File

@@ -240,26 +240,41 @@ Request.prototype.books = function (books, snapshot) {
return this;
};
//
// Remote - access to a remote Ripple server via websocket.
//
// Events:
// 'connect'
// 'connected' (DEPRECATED)
// 'disconnect'
// 'disconnected' (DEPRECATED)
// 'state':
// - 'online' : Connected and subscribed.
// - 'offline' : Not subscribed or not connected.
// 'subscribed' : This indicates stand-alone is available.
//
// Server events:
// 'ledger_closed' : A good indicate of ready to serve.
// 'transaction' : Transactions we receive based on current subscriptions.
// 'transaction_all' : Listening triggers a subscribe to all transactions
// globally in the network.
//------------------------------------------------------------------------------
/**
Interface to manage the connection to a Ripple server.
This implementation uses WebSockets.
Keys for opts:
trusted : truthy, if remote is trusted
websocket_ip
websocket_port
websocket_ssl
trace
maxListeners
Events:
'connect'
'connected' (DEPRECATED)
'disconnect'
'disconnected' (DEPRECATED)
'state':
- 'online' : Connected and subscribed.
- 'offline' : Not subscribed or not connected.
'subscribed' : This indicates stand-alone is available.
Server events:
'ledger_closed' : A good indicate of ready to serve.
'transaction' : Transactions we receive based on current subscriptions.
'transaction_all' : Listening triggers a subscribe to all transactions
globally in the network.
@param opts Connection options.
@param trace
*/
// --> trusted: truthy, if remote is trusted
var Remote = function (opts, trace) {
EventEmitter.call(this);
@@ -340,7 +355,17 @@ var Remote = function (opts, trace) {
var url = (this.websocket_ssl ? "wss://" : "ws://") +
this.websocket_ip + ":" + this.websocket_port;
this.add_server(new Server(this, {url: url}));
var server = new Server (this, {url: url})
if ('maxListeners' in opts)
{
// This is used to remove Emitter warnings
//
server.setMaxListeners (opts.maxListeners)
this.setMaxListeners (opts.maxListeners)
}
this.add_server(server)
this.on('newListener', function (type, listener) {
if ('transaction_all' === type)