@@ -114,20 +114,6 @@ public AblyBase(ClientOptions options, PlatformAgentProvider platformAgentProvid
114
114
push = new Push (this );
115
115
}
116
116
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
-
131
117
/**
132
118
* Causes the connection to close, entering the [{@link io.ably.lib.realtime.ConnectionState#closing} state.
133
119
* 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) {
193
179
* @throws AblyException
194
180
*/
195
181
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 ();
197
187
}
198
188
199
189
/**
@@ -210,10 +200,14 @@ public long time() throws AblyException {
210
200
* This callback is invoked on a background thread
211
201
*/
212
202
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 );
214
208
}
215
209
216
- private Http .Request <Long > timeImpl () {
210
+ private Http .Request <Long > timeImpl (Http http ) {
217
211
final Param [] params = this .options .addRequestIds ? Param .array (Crypto .generateRandomRequestId ()) : null ; // RSC7c
218
212
return http .request (new Http .Execute <Long >() {
219
213
@ Override
@@ -251,7 +245,11 @@ public Long handleResponse(HttpCore.Response response, ErrorInfo error) throws A
251
245
* @throws AblyException
252
246
*/
253
247
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 ();
255
253
}
256
254
257
255
/**
@@ -275,6 +273,10 @@ public PaginatedResult<Stats> stats(Param[] params) throws AblyException {
275
273
* This callback is invoked on a background thread
276
274
*/
277
275
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 ) {
278
280
(new AsyncPaginatedQuery <Stats >(http , "/stats" , HttpUtils .defaultAcceptHeaders (false ), params , StatsReader .statsResponseHandler )).get (callback );
279
281
}
280
282
@@ -298,6 +300,10 @@ public void statsAsync(Param[] params, Callback<AsyncPaginatedResult<Stats>> cal
298
300
* @throws AblyException if it was not possible to complete the request, or an error response was received
299
301
*/
300
302
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 {
301
307
headers = HttpUtils .mergeHeaders (HttpUtils .defaultAcceptHeaders (false ), headers );
302
308
return new HttpPaginatedQuery (http , method , path , headers , params , body ).exec ();
303
309
}
@@ -325,6 +331,10 @@ public HttpPaginatedResponse request(String method, String path, Param[] params,
325
331
* This callback is invoked on a background thread
326
332
*/
327
333
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 ) {
328
338
headers = HttpUtils .mergeHeaders (HttpUtils .defaultAcceptHeaders (false ), headers );
329
339
(new AsyncHttpPaginatedQuery (http , method , path , headers , params , body )).exec (callback );
330
340
}
0 commit comments