@@ -114,20 +114,6 @@ public AblyBase(ClientOptions options, PlatformAgentProvider platformAgentProvid
114114 push = new Push (this );
115115 }
116116
117- /**
118- * We use empty constructor to be able to create proxy implementation of Realtime and Rest client
119- */
120- protected AblyBase (AblyBase underlyingClient , HttpCore httpCore , Http http ) {
121- this .options = underlyingClient .options ;
122- this .auth = underlyingClient .auth ;
123- this .httpCore = httpCore ;
124- this .http = http ;
125- this .platform = underlyingClient .platform ;
126- this .push = underlyingClient .push ;
127- this .channels = underlyingClient .channels ;
128- this .platformAgentProvider = underlyingClient .platformAgentProvider ;
129- }
130-
131117 /**
132118 * Causes the connection to close, entering the [{@link io.ably.lib.realtime.ConnectionState#closing} state.
133119 * Once closed, the library does not attempt to re-establish the connection without an explicit call to
@@ -193,7 +179,11 @@ public void release(String channelName) {
193179 * @throws AblyException
194180 */
195181 public long time () throws AblyException {
196- return timeImpl ().sync ().longValue ();
182+ return time (http );
183+ }
184+
185+ long time (Http http ) throws AblyException {
186+ return timeImpl (http ).sync ();
197187 }
198188
199189 /**
@@ -210,10 +200,14 @@ public long time() throws AblyException {
210200 * This callback is invoked on a background thread
211201 */
212202 public void timeAsync (Callback <Long > callback ) {
213- timeImpl ().async (callback );
203+ timeAsync (http , callback );
204+ }
205+
206+ void timeAsync (Http http , Callback <Long > callback ) {
207+ timeImpl (http ).async (callback );
214208 }
215209
216- private Http .Request <Long > timeImpl () {
210+ private Http .Request <Long > timeImpl (Http http ) {
217211 final Param [] params = this .options .addRequestIds ? Param .array (Crypto .generateRandomRequestId ()) : null ; // RSC7c
218212 return http .request (new Http .Execute <Long >() {
219213 @ Override
@@ -251,7 +245,11 @@ public Long handleResponse(HttpCore.Response response, ErrorInfo error) throws A
251245 * @throws AblyException
252246 */
253247 public PaginatedResult <Stats > stats (Param [] params ) throws AblyException {
254- return new PaginatedQuery <Stats >(http , "/stats" , HttpUtils .defaultAcceptHeaders (false ), params , StatsReader .statsResponseHandler ).get ();
248+ return stats (http , params );
249+ }
250+
251+ PaginatedResult <Stats > stats (Http http , Param [] params ) throws AblyException {
252+ return new PaginatedQuery <>(http , "/stats" , HttpUtils .defaultAcceptHeaders (false ), params , StatsReader .statsResponseHandler ).get ();
255253 }
256254
257255 /**
@@ -275,6 +273,10 @@ public PaginatedResult<Stats> stats(Param[] params) throws AblyException {
275273 * This callback is invoked on a background thread
276274 */
277275 public void statsAsync (Param [] params , Callback <AsyncPaginatedResult <Stats >> callback ) {
276+ statsAsync (http , params , callback );
277+ }
278+
279+ void statsAsync (Http http , Param [] params , Callback <AsyncPaginatedResult <Stats >> callback ) {
278280 (new AsyncPaginatedQuery <Stats >(http , "/stats" , HttpUtils .defaultAcceptHeaders (false ), params , StatsReader .statsResponseHandler )).get (callback );
279281 }
280282
@@ -298,6 +300,10 @@ public void statsAsync(Param[] params, Callback<AsyncPaginatedResult<Stats>> cal
298300 * @throws AblyException if it was not possible to complete the request, or an error response was received
299301 */
300302 public HttpPaginatedResponse request (String method , String path , Param [] params , HttpCore .RequestBody body , Param [] headers ) throws AblyException {
303+ return request (http , method , path , params , body , headers );
304+ }
305+
306+ HttpPaginatedResponse request (Http http , String method , String path , Param [] params , HttpCore .RequestBody body , Param [] headers ) throws AblyException {
301307 headers = HttpUtils .mergeHeaders (HttpUtils .defaultAcceptHeaders (false ), headers );
302308 return new HttpPaginatedQuery (http , method , path , headers , params , body ).exec ();
303309 }
@@ -325,6 +331,10 @@ public HttpPaginatedResponse request(String method, String path, Param[] params,
325331 * This callback is invoked on a background thread
326332 */
327333 public void requestAsync (String method , String path , Param [] params , HttpCore .RequestBody body , Param [] headers , final AsyncHttpPaginatedResponse .Callback callback ) {
334+ requestAsync (http , method , path , params , body , headers , callback );
335+ }
336+
337+ void requestAsync (Http http , String method , String path , Param [] params , HttpCore .RequestBody body , Param [] headers , final AsyncHttpPaginatedResponse .Callback callback ) {
328338 headers = HttpUtils .mergeHeaders (HttpUtils .defaultAcceptHeaders (false ), headers );
329339 (new AsyncHttpPaginatedQuery (http , method , path , headers , params , body )).exec (callback );
330340 }
0 commit comments