Package 

Class AblyBase

  • 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.

    • 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.