public abstract class AblyBase
extends java.lang.Object
implements java.lang.AutoCloseable
AutoCloseable so you can use it in
try-with-resources constructs and have the JDK close it for you.| Modifier and Type | Class and Description |
|---|---|
static interface |
AblyBase.Channels
A collection of Channels associated with an Ably instance.
|
| Modifier and Type | Field and Description |
|---|---|
Auth |
auth
An
Auth object. |
AblyBase.Channels |
channels
An
AblyBase.Channels object. |
Http |
http |
HttpCore |
httpCore |
ClientOptions |
options |
Platform |
platform |
protected PlatformAgentProvider |
platformAgentProvider |
Push |
push
An
Push object. |
| Constructor and Description |
|---|
AblyBase(ClientOptions options,
PlatformAgentProvider platformAgentProvider)
Construct a client object using an Ably
ClientOptions object. |
AblyBase(java.lang.String key,
PlatformAgentProvider platformAgentProvider)
Constructs a client object using an Ably API key or token string.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Causes the connection to close, entering the [
ConnectionState.closing state. |
protected void |
onAuthError(ErrorInfo errorInfo)
Authentication error occurred
|
protected void |
onAuthUpdated(java.lang.String token,
boolean waitForResponse)
Override this method in AblyRealtime and pass updated token to ConnectionManager
|
protected void |
onAuthUpdatedAsync(java.lang.String token,
Auth.AuthUpdateResult authUpdateResult)
Override this method in AblyRealtime and pass updated token to ConnectionManager
|
protected void |
onClientIdSet(java.lang.String clientId)
clientId set by late initialisation
|
PublishResponse[] |
publishBatch(Message.Batch[] pubSpecs,
ChannelOptions channelOptions)
Publish an array of
Message.Batch objects to one or more channels, up to a maximum of 100 channels. |
PublishResponse[] |
publishBatch(Message.Batch[] pubSpecs,
ChannelOptions channelOptions,
Param[] params)
Publish an array of
Message.Batch objects to one or more channels, up to a maximum of 100 channels. |
void |
publishBatchAsync(Message.Batch[] pubSpecs,
ChannelOptions channelOptions,
Callback<PublishResponse[]> callback)
Asynchronously publish an array of
Message.Batch objects to one or more channels, up to a maximum of 100 channels. |
void |
publishBatchAsync(Message.Batch[] pubSpecs,
ChannelOptions channelOptions,
Param[] params,
Callback<PublishResponse[]> callback)
Asynchronously publish an array of
Message.Batch objects to one or more channels, up to a maximum of 100 channels. |
HttpPaginatedResponse |
request(java.lang.String method,
java.lang.String path,
Param[] params,
HttpCore.RequestBody body,
Param[] headers)
Makes a REST request to a provided path.
|
void |
requestAsync(java.lang.String method,
java.lang.String path,
Param[] params,
HttpCore.RequestBody body,
Param[] headers,
AsyncHttpPaginatedResponse.Callback callback)
Makes a async REST request to a provided path.
|
PaginatedResult<Stats> |
stats(Param[] params)
Queries the REST /stats API and retrieves your application's usage statistics.
|
void |
statsAsync(Param[] params,
Callback<AsyncPaginatedResult<Stats>> callback)
Asynchronously queries the REST /stats API and retrieves your application's usage statistics.
|
long |
time()
Retrieves the time from the Ably service as milliseconds
since the Unix epoch.
|
void |
timeAsync(Callback<java.lang.Long> callback)
Asynchronously retrieves the time from the Ably service as milliseconds
since the Unix epoch.
|
public final ClientOptions options
public final Http http
public final HttpCore httpCore
public final AblyBase.Channels channels
AblyBase.Channels object.
Spec: RSN1
public final Platform platform
protected final PlatformAgentProvider platformAgentProvider
public AblyBase(java.lang.String key,
PlatformAgentProvider platformAgentProvider)
throws AblyException
Spec: RSC1
key - The Ably API key or token string used to validate the client.platformAgentProvider - provides platform agent for the agent header.AblyExceptionpublic AblyBase(ClientOptions options, PlatformAgentProvider platformAgentProvider) throws AblyException
ClientOptions object.
Spec: RSC1
options - A ClientOptions object to configure the client connection to Ably.platformAgentProvider - provides platform agent for the agent header.AblyExceptionpublic void close()
throws java.lang.Exception
ConnectionState.closing state.
Once closed, the library does not attempt to re-establish the connection without an explicit call to
Connection.connect().
Spec: RTN12
close in interface java.lang.AutoCloseablejava.lang.Exceptionpublic long time()
throws AblyException
Auth.TokenRequest with
a more accurate timestamp should use the
Auth.AuthOptions.queryTime property instead of this method.
Spec: RSC16
AblyExceptionpublic void timeAsync(Callback<java.lang.Long> callback)
Auth.TokenRequest with
a more accurate timestamp should use the
Auth.AuthOptions.queryTime property instead of this method.
Spec: RSC16
callback - Listener with the time as milliseconds since the Unix epoch.
This callback is invoked on a background thread
public PaginatedResult<Stats> stats(Param[] params) throws AblyException
params - query options:
start (RSC6b1) - The time from which stats are retrieved, specified as milliseconds since the Unix epoch.
end (RSC6b1) - The time until stats are retrieved, specified as milliseconds since the Unix epoch.
direction (RSC6b2) - The order for which stats are returned in. Valid values are backwards which orders stats from most recent to oldest, or forwards which orders stats from oldest to most recent. The default is backwards.
limit (RSC6b3) - An upper limit on the number of stats returned. The default is 100, and the maximum is 1000.
unit (RSC6b4) - minute, hour, day or month. Based on the unit selected, the given start or end times are rounded down to the start of the relevant interval depending on the unit granularity of the query.)
Spec: RSC6a
PaginatedResult object containing an array of Stats objects.AblyExceptionpublic void statsAsync(Param[] params, Callback<AsyncPaginatedResult<Stats>> callback)
params - query options:
start (RSC6b1) - The time from which stats are retrieved, specified as milliseconds since the Unix epoch.
end (RSC6b1) - The time until stats are retrieved, specified as milliseconds since the Unix epoch.
direction (RSC6b2) - The order for which stats are returned in. Valid values are backwards which orders stats from most recent to oldest, or forwards which orders stats from oldest to most recent. The default is backwards.
limit (RSC6b3) - An upper limit on the number of stats returned. The default is 100, and the maximum is 1000.
unit (RSC6b4) - minute, hour, day or month. Based on the unit selected, the given start or end times are rounded down to the start of the relevant interval depending on the unit granularity of the query.)
Spec: RSC6a
callback - Listener which returns a AsyncPaginatedResult object containing an array of Stats objects.
This callback is invoked on a background thread
public HttpPaginatedResponse request(java.lang.String method, java.lang.String path, Param[] params, HttpCore.RequestBody body, Param[] headers) throws AblyException
Spec: RSC19
method - The request method to use, such as GET, POST.path - The request path.params - The parameters to include in the URL query of the request.
The parameters depend on the endpoint being queried.
See the REST API reference
for the available parameters of each endpoint.body - The RequestBody of the request.headers - Additional HTTP headers to include in the request.HttpPaginatedResponse object returned by the HTTP request, containing an empty or JSON-encodable object.AblyException - if it was not possible to complete the request, or an error response was receivedpublic void requestAsync(java.lang.String method,
java.lang.String path,
Param[] params,
HttpCore.RequestBody body,
Param[] headers,
AsyncHttpPaginatedResponse.Callback callback)
Spec: RSC19
method - The request method to use, such as GET, POST.path - The request path.params - The parameters to include in the URL query of the request.
The parameters depend on the endpoint being queried.
See the REST API reference
for the available parameters of each endpoint.body - The RequestBody of the request.headers - Additional HTTP headers to include in the request.callback - called with the asynchronous result,
returns an AsyncHttpPaginatedResponse object returned by the HTTP request,
containing an empty or JSON-encodable object.
This callback is invoked on a background thread
@Experimental public PublishResponse[] publishBatch(Message.Batch[] pubSpecs, ChannelOptions channelOptions) throws AblyException
Message.Batch objects to one or more channels, up to a maximum of 100 channels.
Each Message.Batch object can contain a single message or an array of messages.
Returns an array of PublishResponse object.
Spec: BO2a
pubSpecs - An array of Message.Batch objects.channelOptions - A ClientOptions object to configure the client connection to Ably.PublishResponse object.AblyException@Experimental public PublishResponse[] publishBatch(Message.Batch[] pubSpecs, ChannelOptions channelOptions, Param[] params) throws AblyException
Message.Batch objects to one or more channels, up to a maximum of 100 channels.
Each Message.Batch object can contain a single message or an array of messages.
Returns an array of PublishResponse object.
Spec: BO2a
pubSpecs - An array of Message.Batch objects.channelOptions - A ClientOptions object to configure the client connection to Ably.params - params to pass into the initial queryPublishResponse object.AblyException@Experimental public void publishBatchAsync(Message.Batch[] pubSpecs, ChannelOptions channelOptions, Callback<PublishResponse[]> callback) throws AblyException
Message.Batch objects to one or more channels, up to a maximum of 100 channels.
Each Message.Batch object can contain a single message or an array of messages.
Returns an array of PublishResponse object.
Spec: BO2a
pubSpecs - An array of Message.Batch objects.channelOptions - A ClientOptions object to configure the client connection to Ably.callback - callback A callback with PublishResponse object.
This callback is invoked on a background thread
AblyException@Experimental public void publishBatchAsync(Message.Batch[] pubSpecs, ChannelOptions channelOptions, Param[] params, Callback<PublishResponse[]> callback) throws AblyException
Message.Batch objects to one or more channels, up to a maximum of 100 channels.
Each Message.Batch object can contain a single message or an array of messages.
Returns an array of PublishResponse object.
Spec: BO2a
pubSpecs - An array of Message.Batch objects.channelOptions - A ClientOptions object to configure the client connection to Ably.params - params to pass into the initial querycallback - A callback with PublishResponse object.
This callback is invoked on a background thread
AblyExceptionprotected void onAuthUpdated(java.lang.String token,
boolean waitForResponse)
throws AblyException
token - new tokenwaitForResponse - wait for server response before returning from methodAblyExceptionprotected void onAuthUpdatedAsync(java.lang.String token,
Auth.AuthUpdateResult authUpdateResult)
token - new tokenauthUpdateResult - Callback resultprotected void onAuthError(ErrorInfo errorInfo)
protected void onClientIdSet(java.lang.String clientId)