Package io.ably.lib.rest
Class AblyBase
- java.lang.Object
-
- io.ably.lib.rest.AblyBase
-
- Direct Known Subclasses:
AblyRest
public abstract class AblyBase extends java.lang.ObjectAblyBase The top-level class to be instanced for the Ably REST library.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classAblyBase.ChannelsA collection of Channels associated with an Ably instance.
-
Constructor Summary
Constructors Constructor Description AblyBase(ClientOptions options)Instance the Ably library with the given options.AblyBase(java.lang.String key)Instance the Ably library using a key only.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidonAuthError(ErrorInfo errorInfo)Authentication error occurredprotected voidonAuthUpdated(java.lang.String token, boolean waitForResponse)Override this method in AblyRealtime and pass updated token to ConnectionManagerprotected voidonClientIdSet(java.lang.String clientId)clientId set by late initialisationPublishResponse[]publishBatch(Message.Batch[] pubSpecs, ChannelOptions channelOptions)Publish a messages on one or more channels.voidpublishBatchAsync(Message.Batch[] pubSpecs, ChannelOptions channelOptions, Callback<PublishResponse[]> callback)HttpPaginatedResponserequest(java.lang.String method, java.lang.String path, Param[] params, HttpCore.RequestBody body, Param[] headers)Make a generic HTTP request against an endpoint representing a collection of some type; this is to provide a forward compatibility path for new APIs.voidrequestAsync(java.lang.String method, java.lang.String path, Param[] params, HttpCore.RequestBody body, Param[] headers, AsyncHttpPaginatedResponse.Callback callback)Make an async generic HTTP request against an endpoint representing a collection of some type; this is to provide a forward compatibility path for new APIs.PaginatedResult<Stats>stats(Param[] params)Request usage statistics for this application.voidstatsAsync(Param[] params, Callback<AsyncPaginatedResult<Stats>> callback)Asynchronously obtain usage statistics for this application using the REST API.longtime()Obtain the time from the Ably service.voidtimeAsync(Callback<java.lang.Long> callback)Asynchronously obtain the time from the Ably service.
-
-
-
Field Detail
-
options
public final ClientOptions options
-
http
public final Http http
-
httpCore
public final HttpCore httpCore
-
auth
public final Auth auth
-
channels
public final AblyBase.Channels channels
-
platform
public final Platform platform
-
push
public final Push push
-
-
Constructor Detail
-
AblyBase
public AblyBase(java.lang.String key) throws AblyExceptionInstance the Ably library using a key only. This is simply a convenience constructor for the simplest case of instancing the library with a key for basic authentication and no other options.- Parameters:
key- ; String key (obtained from application dashboard)- Throws:
AblyException
-
AblyBase
public AblyBase(ClientOptions options) throws AblyException
Instance the Ably library with the given options.- Parameters:
options- : seeClientOptionsfor options- Throws:
AblyException
-
-
Method Detail
-
time
public long time() throws AblyExceptionObtain the time from the Ably service. This may be required on clients that do not have access to a sufficiently well maintained time source, to provide timestamps for use in token requests- Returns:
- time in millis since the epoch
- Throws:
AblyException
-
timeAsync
public void timeAsync(Callback<java.lang.Long> callback)
Asynchronously obtain the time from the Ably service. This may be required on clients that do not have access to a sufficiently well maintained time source, to provide timestamps for use in token requests- Parameters:
callback-
-
stats
public PaginatedResult<Stats> stats(Param[] params) throws AblyException
Request usage statistics for this application. Returned stats are application-wide and not just relating to this instance.- Parameters:
params- query options: see Ably REST API documentation for available options- Returns:
- a PaginatedResult of Stats records for the requested params
- Throws:
AblyException
-
statsAsync
public void statsAsync(Param[] params, Callback<AsyncPaginatedResult<Stats>> callback)
Asynchronously obtain usage statistics for this application using the REST API.- Parameters:
params- : the request params. See the Ably REST APIcallback-
-
request
public HttpPaginatedResponse request(java.lang.String method, java.lang.String path, Param[] params, HttpCore.RequestBody body, Param[] headers) throws AblyException
Make a generic HTTP request against an endpoint representing a collection of some type; this is to provide a forward compatibility path for new APIs.- Parameters:
method- : the HTTP method to use (see constants in io.ably.lib.httpCore.HttpCore)path- : the path component of the resource URIparams- (optional; may be null): any parameters to send with the request; see API-specific documentationbody- (optional; may be null): an instance of RequestBody; either a JSONRequestBody or ByteArrayRequestBodyheaders- (optional; may be null): any additional headers to send; see API-specific documentation- Returns:
- a page of results, each represented as a JsonElement
- Throws:
AblyException- if it was not possible to complete the request, or an error response was received
-
requestAsync
public void requestAsync(java.lang.String method, java.lang.String path, Param[] params, HttpCore.RequestBody body, Param[] headers, AsyncHttpPaginatedResponse.Callback callback)Make an async generic HTTP request against an endpoint representing a collection of some type; this is to provide a forward compatibility path for new APIs.- Parameters:
method- : the HTTP method to use (see constants in io.ably.lib.httpCore.HttpCore)path- : the path component of the resource URIparams- (optional; may be null): any parameters to send with the request; see API-specific documentationbody- (optional; may be null): an instance of RequestBody; either a JSONRequestBody or ByteArrayRequestBodyheaders- (optional; may be null): any additional headers to send; see API-specific documentationcallback- : called with the asynchronous result
-
publishBatch
@Experimental public PublishResponse[] publishBatch(Message.Batch[] pubSpecs, ChannelOptions channelOptions) throws AblyException
Publish a messages on one or more channels. When there are messages to be sent on multiple channels simultaneously, it is more efficient to use this method to publish them in a single request, as compared with publishing via multiple independent requests.- Throws:
AblyException
-
publishBatchAsync
@Experimental public void publishBatchAsync(Message.Batch[] pubSpecs, ChannelOptions channelOptions, Callback<PublishResponse[]> callback) throws AblyException
- Throws:
AblyException
-
onAuthUpdated
protected void onAuthUpdated(java.lang.String token, boolean waitForResponse) throws AblyExceptionOverride this method in AblyRealtime and pass updated token to ConnectionManager- Parameters:
token- new tokenwaitForResponse- wait for server response before returning from method- Throws:
AblyException
-
onAuthError
protected void onAuthError(ErrorInfo errorInfo)
Authentication error occurred
-
onClientIdSet
protected void onClientIdSet(java.lang.String clientId)
clientId set by late initialisation
-
-