-
- All Implemented Interfaces:
-
java.lang.AutoCloseable
public abstract class AblyBase implements AutoCloseable
A client that offers a simple stateless API to interact directly with Ably's REST API. This class implements AutoCloseable so you can use it in try-with-resources constructs and have the JDK close it for you.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceAblyBase.ChannelsA collection of Channels associated with an Ably instance.
-
Constructor Summary
Constructors Constructor Description AblyBase(String key, PlatformAgentProvider platformAgentProvider)Constructs a client object using an Ably API key or token string. AblyBase(ClientOptions options, PlatformAgentProvider platformAgentProvider)Construct a client object using an Ably ClientOptions object.
-
Method Summary
Modifier and Type Method Description voidclose()Causes the connection to close, entering the [closing state. longtime()Retrieves the time from the Ably service as millisecondssince the Unix epoch. voidtimeAsync(Callback<Long> callback)Asynchronously retrieves the time from the Ably service as millisecondssince the Unix epoch. PaginatedResult<Stats>stats(Array<Param> params)Queries the REST /stats API and retrieves your application's usage statistics. voidstatsAsync(Array<Param> params, Callback<AsyncPaginatedResult<Stats>> callback)Asynchronously queries the REST /stats API and retrieves your application's usage statistics. HttpPaginatedResponserequest(String method, String path, Array<Param> params, HttpCore.RequestBody body, Array<Param> headers)Makes a REST request to a provided path. voidrequestAsync(String method, String path, Array<Param> params, HttpCore.RequestBody body, Array<Param> headers, AsyncHttpPaginatedResponse.Callback callback)Makes a async REST request to a provided path. Array<PublishResponse>publishBatch(Array<Message.Batch> pubSpecs, ChannelOptions channelOptions)Publish an array of Message.Batch objects to one or more channels, up to a maximum of 100 channels. Array<PublishResponse>publishBatch(Array<Message.Batch> pubSpecs, ChannelOptions channelOptions, Array<Param> params)Publish an array of Message.Batch objects to one or more channels, up to a maximum of 100 channels. voidpublishBatchAsync(Array<Message.Batch> pubSpecs, ChannelOptions channelOptions, Callback<Array<PublishResponse>> callback)Asynchronously publish an array of Message.Batch objects to one or more channels, up to a maximum of 100 channels. voidpublishBatchAsync(Array<Message.Batch> pubSpecs, ChannelOptions channelOptions, Array<Param> params, Callback<Array<PublishResponse>> callback)Asynchronously publish an array of Message.Batch objects to one or more channels, up to a maximum of 100 channels. -
-
Constructor Detail
-
AblyBase
AblyBase(String key, PlatformAgentProvider platformAgentProvider)
Constructs a client object using an Ably API key or token string.- Parameters:
key- The Ably API key or token string used to validate the client.platformAgentProvider- provides platform agent for the agent header.
-
AblyBase
AblyBase(ClientOptions options, PlatformAgentProvider platformAgentProvider)
Construct a client object using an Ably ClientOptions object.- Parameters:
options- A ClientOptions object to configure the client connection to Ably.platformAgentProvider- provides platform agent for the agent header.
-
-
Method Detail
-
close
void close()
Causes the connection to close, entering the [closing state.Once closed, the library does not attempt to re-establish the connection without an explicit call to connect.
Spec: RTN12
-
time
long time()
Retrieves the time from the Ably service as millisecondssince the Unix epoch. Clients that do not have accessto a sufficiently well maintained time source and wishto issue Ably Auth.TokenRequest witha more accurate timestamp should use the queryTime property instead of this method.
Spec: RSC16
-
timeAsync
void timeAsync(Callback<Long> callback)
Asynchronously retrieves the time from the Ably service as millisecondssince the Unix epoch. Clients that do not have accessto a sufficiently well maintained time source and wishto issue Ably Auth.TokenRequest witha more accurate timestamp should use the queryTime property instead of this method.
Spec: RSC16
- Parameters:
callback- Listener with the time as milliseconds since the Unix epoch.
-
stats
PaginatedResult<Stats> stats(Array<Param> params)
Queries the REST /stats API and retrieves your application's usage statistics.
- Parameters:
params- query options:start (RSC6b1) - The time from which stats are retrieved, specified as milliseconds since the Unix epoch.
-
statsAsync
void statsAsync(Array<Param> params, Callback<AsyncPaginatedResult<Stats>> callback)
Asynchronously queries the REST /stats API and retrieves your application's usage statistics.
- Parameters:
params- query options:start (RSC6b1) - The time from which stats are retrieved, specified as milliseconds since the Unix epoch.callback- Listener which returns a AsyncPaginatedResult object containing an array of Stats objects.
-
request
HttpPaginatedResponse request(String method, String path, Array<Param> params, HttpCore.RequestBody body, Array<Param> headers)
Makes a REST request to a provided path. This is provided as a conveniencefor developers who wish to use REST API functionality that is either notdocumented or is not yet included in the public API, without having todirectly handle features such as authentication, paging, fallback hosts,MsgPack and JSON support.
Spec: RSC19
- Parameters:
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.body- The RequestBody of the request.headers- Additional HTTP headers to include in the request.
-
requestAsync
void requestAsync(String method, String path, Array<Param> params, HttpCore.RequestBody body, Array<Param> headers, AsyncHttpPaginatedResponse.Callback callback)
Makes a async REST request to a provided path. This is provided as a conveniencefor developers who wish to use REST API functionality that is either notdocumented or is not yet included in the public API, without having todirectly handle features such as authentication, paging, fallback hosts,MsgPack and JSON support.
Spec: RSC19
- Parameters:
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.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.
-
publishBatch
@Experimental() Array<PublishResponse> publishBatch(Array<Message.Batch> pubSpecs, ChannelOptions channelOptions)
Publish an array of 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
- Parameters:
pubSpecs- An array of Message.Batch objects.channelOptions- A ClientOptions object to configure the client connection to Ably.
-
publishBatch
@Experimental() Array<PublishResponse> publishBatch(Array<Message.Batch> pubSpecs, ChannelOptions channelOptions, Array<Param> params)
Publish an array of 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
- Parameters:
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 query
-
publishBatchAsync
@Experimental() void publishBatchAsync(Array<Message.Batch> pubSpecs, ChannelOptions channelOptions, Callback<Array<PublishResponse>> callback)
Asynchronously publish an array of 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
- Parameters:
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.
-
publishBatchAsync
@Experimental() void publishBatchAsync(Array<Message.Batch> pubSpecs, ChannelOptions channelOptions, Array<Param> params, Callback<Array<PublishResponse>> callback)
Asynchronously publish an array of 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
- Parameters:
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.
-
-
-
-