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 implements java.lang.AutoCloseable
AblyRealtime 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 classAblyRealtime.ChannelsA collection of the Channels associated with this Realtime instance.
-
Field Summary
Fields Modifier and Type Field Description AblyRealtime.ChannelschannelsThe#Channelsassociated with this instance.ConnectionconnectionTheConnectionobject 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.-
Methods inherited from class io.ably.lib.rest.AblyBase
onClientIdSet, publishBatch, publishBatchAsync, request, requestAsync, stats, statsAsync, time, timeAsync
-
-
-
-
Field Detail
-
connection
public final Connection connection
TheConnectionobject for this instance.
-
channels
public AblyRealtime.Channels channels
The#Channelsassociated with this instance.
-
-
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().- Specified by:
closein interfacejava.lang.AutoCloseable
-
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
-
onAuthError
protected void onAuthError(ErrorInfo errorInfo)
Authentication error occurred- Overrides:
onAuthErrorin classAblyBase
-
-