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
A client that extends the functionality of theAblyRestand provides additional realtime-specific features. 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.ChannelschannelsAAblyRealtime.Channelsobject.ConnectionconnectionTheConnectionobject for this instance.
-
Constructor Summary
Constructors Constructor Description AblyRealtime(ClientOptions options)Constructs a RealtimeClient object using an AblyClientOptionsobject.AblyRealtime(java.lang.String key)Constructs a Realtime client object using an Ably API key or token string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()CallsConnection.close()and causes the connection to close, entering the closing state.voidconnect()CallsConnection.connect()and causes the connection to open, entering the connecting state.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.Spec: RTC2
-
channels
public final AblyRealtime.Channels channels
AAblyRealtime.Channelsobject.Spec: RTC3, RTS1
-
-
Constructor Detail
-
AblyRealtime
public AblyRealtime(java.lang.String key) throws AblyExceptionConstructs 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 AblyClientOptionsobject.Spec: RSC1
- Parameters:
options- AClientOptionsobject.- Throws:
AblyException
-
-
Method Detail
-
connect
public void connect()
CallsConnection.connect()and causes the connection to open, entering the connecting state. Explicitly calling connect() is unnecessary unless theClientOptions.autoConnectproperty is disabled.Spec: RTN11
-
close
public void close()
CallsConnection.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 toConnection.connect().Spec: RTN12
-
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
-
-