Class AblyBase

  • Direct Known Subclasses:
    AblyRest

    public abstract class AblyBase
    extends java.lang.Object
    AblyBase The top-level class to be instanced for the Ably REST library.
    • Constructor Detail

      • AblyBase

        public AblyBase​(java.lang.String key)
                 throws AblyException
        Instance 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
    • Method Detail

      • time

        public long time()
                  throws AblyException
        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
        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 API
        callback -
      • 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 URI
        params - (optional; may be null): any parameters to send with the request; see API-specific documentation
        body - (optional; may be null): an instance of RequestBody; either a JSONRequestBody or ByteArrayRequestBody
        headers - (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 URI
        params - (optional; may be null): any parameters to send with the request; see API-specific documentation
        body - (optional; may be null): an instance of RequestBody; either a JSONRequestBody or ByteArrayRequestBody
        headers - (optional; may be null): any additional headers to send; see API-specific documentation
        callback - : 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
      • onAuthUpdated

        protected void onAuthUpdated​(java.lang.String token,
                                     boolean waitForResponse)
                              throws AblyException
        Override this method in AblyRealtime and pass updated token to ConnectionManager
        Parameters:
        token - new token
        waitForResponse - 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