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 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.-
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
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 Details
-
connection
TheConnectionobject for this instance.Spec: RTC2
-
channels
AAblyRealtime.Channelsobject.Spec: RTC3, RTS1
-
-
Constructor Details
-
AblyRealtime
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
Constructs a RealtimeClient object using an AblyClientOptionsobject.Spec: RSC1
- Parameters:
options- AClientOptionsobject.- Throws:
AblyException
-
-
Method Details
-
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
Authentication token has changed.- Overrides:
onAuthUpdatedin classAblyBase- Parameters:
token- new tokenwaitForResponse- wait for server response before returning from method- Throws:
AblyException
-
onAuthUpdatedAsync
Authentication token has changed. Async version- Overrides:
onAuthUpdatedAsyncin classAblyBase- Parameters:
token- new tokenauthUpdateResult- Callback result
-
onAuthError
Authentication error occurred- Overrides:
onAuthErrorin classAblyBase
-