Class RealTimeConnection

java.lang.Object
com.amazonaws.ivs.broadcast.RealTimeConnection
All Implemented Interfaces:
Releasable

@RequiresApi(api=28) public final class RealTimeConnection extends Object implements 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.

  • 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

      public void connect() throws BroadcastException
      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

      public void setListener(@Nullable RealTimeConnection.Listener listener)
      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:
      release in interface Releasable
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable