From 498e7df622976569f6cacedf1c166e5fd2ab20ee Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 1 May 2013 16:16:50 -0700 Subject: [PATCH] Add maxListeners config option --- src/js/remote.js | 65 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/src/js/remote.js b/src/js/remote.js index 94181346..7430fc1f 100644 --- a/src/js/remote.js +++ b/src/js/remote.js @@ -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)