nl_tokens: The AppClient is a high - level JSON - RPC client with support for method retries and reconnecting .
pl_tokens: function AppClient ( URL , options ) { if ( ! ( this instanceof AppClient ) ) { return new AppClient ( URL , options ) ; } options = options || { } ; //TODO: Implement option passing. var transport = options . transport || new SocketTransport ( URL ) ; var RPC = options . RPC || <mask> JSONRPC ( transport ) ; var commander = options . commander || new Commander ( RPC ) ; // Every time we manage to connect, all pending calls are retried: transport . on ( 'connect' , function ( ) { setTimeout ( function ( ) { commander . triggerRetries ( ) ; } , 10000 * Math . random ( ) ) ; } ) ; // Make transport errors non-fatal: transport . on ( 'error' , function ( ) { } ) ; //TODO: Listen for drop notifications and immediately reject all RPCs with an { isRetriable: true } error. // Initialize getters so that all underlying resources may be conveniently accessed. Object . defineProperties ( this , { transport : { enumerable : true , get : function ( ) { return transport ; } } , RPC : { enumerable : true , get : function ( ) { return RPC ; } } , commander : { enumerable : true , get : function ( ) { return commander ; } } } ) ; // Start the transport right away! transport . start ( ) ; }