Class AblyRealtime

All Implemented Interfaces:
AutoCloseable

public class AblyRealtime extends AblyRest
A client that extends the functionality of the AblyRest and provides additional realtime-specific features. This class implements AutoCloseable so you can use it in try-with-resources constructs and have the JDK close it for you.
  • Field Details

  • Constructor Details

    • AblyRealtime

      public AblyRealtime(String key) throws AblyException
      Constructs a Realtime client object using an Ably API key or token string.

      Spec: RSC1

      Parameters:
      key - The Ably API key or token string used to validate the client.
      Throws:
      AblyException
    • AblyRealtime

      public AblyRealtime(ClientOptions options) throws AblyException
      Constructs a RealtimeClient object using an Ably ClientOptions object.

      Spec: RSC1

      Parameters:
      options - A ClientOptions object.
      Throws:
      AblyException
  • Method Details

    • connect

      public void connect()
      Calls Connection.connect() and causes the connection to open, entering the connecting state. Explicitly calling connect() is unnecessary unless the ClientOptions.autoConnect property is disabled.

      Spec: RTN11

    • close

      public void close()
      Calls Connection.close() and causes the connection to close, entering the closing state. Once closed, the library will not attempt to re-establish the connection without an explicit call to Connection.connect().

      Spec: RTN12

      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class AblyBase
    • onAuthUpdated

      protected void onAuthUpdated(String token, boolean waitForResponse) throws AblyException
      Authentication token has changed.
      Overrides:
      onAuthUpdated in class AblyBase
      Parameters:
      token - new token
      waitForResponse - wait for server response before returning from method
      Throws:
      AblyException
    • onAuthUpdatedAsync

      protected void onAuthUpdatedAsync(String token, Auth.AuthUpdateResult authUpdateResult)
      Authentication token has changed. Async version
      Overrides:
      onAuthUpdatedAsync in class AblyBase
      Parameters:
      token - new token
      authUpdateResult - Callback result
    • onAuthError

      protected void onAuthError(ErrorInfo errorInfo)
      Authentication error occurred
      Overrides:
      onAuthError in class AblyBase
    • setChannelSerialsFromRecoverOption

      protected void setChannelSerialsFromRecoverOption(Map<String,String> serials)
    • getChannelSerials

      protected Map<String,String> getChannelSerials()