Package com.amazonaws.ivs.broadcast
Class RealTimeConnection
java.lang.Object
com.amazonaws.ivs.broadcast.RealTimeConnection
- All Implemented Interfaces:
Releasable
A shared connection that multiple
Stage instances can use to communicate
with the IVS real-time service over a single physical network transport.
You can create a RealTimeConnection, pass it to one or more Stage instances,
and then call Stage.join() on any of those stages. If you have not yet called
connect() on the connection, the SDK auto-connects it the first time a stage calls
join(). You can also call connect() explicitly before joining any stage to
establish the transport in advance, which will cause future stage joins over this connection
to connect faster.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA listener that receives connection state changes.static enumThe connection state of aRealTimeConnection. -
Constructor Summary
ConstructorsConstructorDescriptionRealTimeConnection(android.content.Context context, String connectionToken) Create a RealTimeConnection with a connection token. -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()Opens the connection to the IVS Real-Time service.voidCloses the connection.protected voidfinalize()voidrelease()Release native resources.voidsetListener(RealTimeConnection.Listener listener) Set a listener for connection state changes.
-
Constructor Details
-
RealTimeConnection
public RealTimeConnection(@NonNull android.content.Context context, @NonNull String connectionToken) throws BroadcastException Create a RealTimeConnection with a connection token.- Parameters:
context- Application context.connectionToken- A connection token used to authenticate with IVS- Throws:
BroadcastException- if the token is invalid or the connection cannot be created.
-
-
Method Details
-
connect
Opens the connection to the IVS Real-Time service.You do not need to call this method before joining a stage. If the connection is not yet open when a stage calls
Stage.join(), it is opened automatically. Call this method explicitly if you want to establish the transport before joining any stage — for example, to reduce time-to-video.- Throws:
BroadcastException- if the connection cannot be established.
-
disconnect
public void disconnect()Closes the connection. This will leave any connected Stage, and will prevent any unconnected Stages from joining. -
setListener
Set a listener for connection state changes.- Parameters:
listener- The listener to receive callbacks, or null to remove the current listener.
-
release
public void release()Release native resources. Must be called when the connection is no longer needed. After calling this, the connection cannot be reused.- Specified by:
releasein interfaceReleasable
-
finalize
-