Package io.ably.lib.realtime
Class AblyRealtime
- java.lang.Object
-
- io.ably.lib.rest.AblyBase
-
- io.ably.lib.rest.AblyRest
-
- io.ably.lib.realtime.AblyRealtime
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class AblyRealtime extends AblyRest
The top-level class to be instanced for the Ably Realtime library. This class implementsAutoCloseableso 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 static interfaceAblyRealtime.ChannelsA collection of Channels associated with this Ably Realtime instance.
-
Field Summary
Fields Modifier and Type Field Description AblyRealtime.ChannelschannelsConnectionconnectionTheConnectionobject for this instance.
-
Constructor Summary
Constructors Constructor Description AblyRealtime(ClientOptions options)Instance the Ably library with the given options.AblyRealtime(java.lang.String key)Instance the Ably library using a key only.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close this instance.voidconnect()Initiate a connection.protected voidonAuthError(ErrorInfo errorInfo)Authentication error occurredprotected voidonAuthUpdated(java.lang.String token, boolean waitForResponse)Authentication token has changed.protected voidonAuthUpdatedAsync(java.lang.String token, Auth.AuthUpdateResult authUpdateResult)Authentication token has changed.-
Methods inherited from class io.ably.lib.rest.AblyBase
onClientIdSet, publishBatch, publishBatch, publishBatchAsync, publishBatchAsync, request, requestAsync, stats, statsAsync, time, timeAsync
-
-
-
-
Field Detail
-
connection
public final Connection connection
TheConnectionobject for this instance.
-
channels
public final AblyRealtime.Channels channels
-
-
Constructor Detail
-
AblyRealtime
public AblyRealtime(java.lang.String key) throws AblyExceptionInstance 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
-
AblyRealtime
public AblyRealtime(ClientOptions options) throws AblyException
Instance the Ably library with the given options.- Parameters:
options- seeClientOptionsfor options- Throws:
AblyException
-
-
Method Detail
-
connect
public void connect()
Initiate a connection.Connection.connect().
-
close
public void close()
Close this instance. This closes the connection. The connection can be re-opened by callingConnection.connect().
-
onAuthUpdated
protected void onAuthUpdated(java.lang.String token, boolean waitForResponse) throws AblyExceptionAuthentication token has changed.- Overrides:
onAuthUpdatedin classAblyBase- Parameters:
token- new tokenwaitForResponse- wait for server response before returning from method- Throws:
AblyException
-
onAuthUpdatedAsync
protected void onAuthUpdatedAsync(java.lang.String token, Auth.AuthUpdateResult authUpdateResult)Authentication token has changed. Async version- Overrides:
onAuthUpdatedAsyncin classAblyBase- Parameters:
token- new tokenauthUpdateResult- Callback result
-
onAuthError
protected void onAuthError(ErrorInfo errorInfo)
Authentication error occurred- Overrides:
onAuthErrorin classAblyBase
-
-