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:
AutoCloseable
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
Modifier and TypeClassDescriptionstatic interface
A collection of Channels associated with this Ably Realtime instance. -
Field Summary
Modifier and TypeFieldDescriptionfinal AblyRealtime.Channels
AAblyRealtime.Channels
object.final Connection
TheConnection
object for this instance. -
Constructor Summary
ConstructorDescriptionAblyRealtime
(ClientOptions options) Constructs a RealtimeClient object using an AblyClientOptions
object.AblyRealtime
(String key) Constructs a Realtime client object using an Ably API key or token string. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
CallsConnection.close()
and causes the connection to close, entering the closing state.void
connect()
CallsConnection.connect()
and causes the connection to open, entering the connecting state.protected void
onAuthError
(ErrorInfo errorInfo) Authentication error occurredprotected void
onAuthUpdated
(String token, boolean waitForResponse) Authentication token has changed.protected void
onAuthUpdatedAsync
(String token, Auth.AuthUpdateResult authUpdateResult) Authentication token has changed.protected void
setChannelSerialsFromRecoverOption
(Map<String, String> serials) Methods inherited from class io.ably.lib.rest.AblyBase
onClientIdSet, publishBatch, publishBatch, publishBatchAsync, publishBatchAsync, request, requestAsync, stats, statsAsync, time, timeAsync
-
Field Details
-
connection
TheConnection
object for this instance.Spec: RTC2
-
channels
AAblyRealtime.Channels
object.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 AblyClientOptions
object.Spec: RSC1
- Parameters:
-
options
- AClientOptions
object. - 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.autoConnect
property 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
- Specified by:
-
close
in interfaceAutoCloseable
- Overrides:
-
close
in classAblyBase
-
onAuthUpdated
Authentication token has changed.- Overrides:
-
onAuthUpdated
in classAblyBase
- Parameters:
-
token
- new token -
waitForResponse
- wait for server response before returning from method - Throws:
AblyException
-
onAuthUpdatedAsync
Authentication token has changed. Async version- Overrides:
-
onAuthUpdatedAsync
in classAblyBase
- Parameters:
-
token
- new token -
authUpdateResult
- Callback result
-
onAuthError
Authentication error occurred- Overrides:
-
onAuthError
in classAblyBase
-
setChannelSerialsFromRecoverOption
-
getChannelSerials
-