Interface Space.Listener

  • Enclosing class:
    Space

    public static interface Space.Listener
    The Listener interface is the way applications receive information about events occurring in a Space. Implementations of this interface must be bound to variables that applications keep track of as they are kept as WeakReferences. (This is to defend against keeping a Space active in the event of an Activity crash).

    Listeners start receiving events after join, and will cease after they have left. If a Space is already active and another listener joins then both listeners will receive events, but the new listener will also receive events sufficient to recreate the state of the Space. This is to make user interface development easier.

    All these callbacks into the application occur on the UI thread. The SDK is multithreaded and all calls into it should be safe as we handle the threading for you.
    • Method Detail

      • onJoined

        default void onJoined​(Space space,
                              LocalParticipant localParticipant)
        Called when you have successfully joined a Space. At this point the participant ID is valid and accepted by the server and you can publish and unpublish tracks.
        Parameters:
        space - The Space this callback applies to
        localParticipant - The resulting LocalParticipant
      • onLeft

        default void onLeft​(Space space,
                            LocalParticipant localParticipant)
        Called when you have successfully left a Space.
        Parameters:
        space - The Space this callback applies to
        localParticipant -
      • onLocalParticipantReconnecting

        default void onLocalParticipantReconnecting​(Space space,
                                                    LocalParticipant localParticipant)
        Called when we should be connected and a disconnect causes us to try reconnecting.
        Parameters:
        space -
        localParticipant -
      • onLocalParticipantReconnected

        default void onLocalParticipantReconnected​(Space space,
                                                   LocalParticipant localParticipant)
        Called when the LocalParticipant has successfully reconnected after having gone through reconnection.
        Parameters:
        space -
        localParticipant -
      • onLocalParticipantReconnectionFailure

        default void onLocalParticipantReconnectionFailure​(Space space,
                                                           LocalParticipant localParticipant)
        Called when the automatic retries for rejoining the Space have failed to complete.
        Parameters:
        space -
        localParticipant -
      • onParticipantJoined

        default void onParticipantJoined​(Space space,
                                         RemoteParticipant remoteParticipant)
        Called when another participant has joined the space.

        Also called when you join a Space and it has existing participants.
        Parameters:
        space - The Space this callback applies to
        remoteParticipant -
      • onParticipantLeft

        default void onParticipantLeft​(Space space,
                                       RemoteParticipant remoteParticipant)
        Called when another participant has left the space.
        Parameters:
        space - The Space this callback applies to
        remoteParticipant -
      • onParticipantTrackPublished

        default void onParticipantTrackPublished​(Space space,
                                                 Participant participant,
                                                 Track track)
        Called when a participant has published a track.

        This does not mean we start receiving media for it, just that someone else is publishing. To receive the media you must also be subscribed.

        Right now we auto-subscribe to all added tracks, so this will be shortly followed by onParticipantTrackSubscribed.
        Parameters:
        space - The Space this callback applies to
        participant -
        track -
      • onParticipantTrackUnpublished

        default void onParticipantTrackUnpublished​(Space space,
                                                   Participant participant,
                                                   Track track)
        Called when a participant has unpublished a track
        Parameters:
        space - The Space this callback applies to
        participant -
        track -
      • onParticipantTrackSubscribed

        default void onParticipantTrackSubscribed​(Space space,
                                                  Participant participant,
                                                  Track track)
        Called when we have successfully subscribed to a track.

        This means media should be streaming to the track. If it's audio it will play automatically, for video you will need to attach the Track to an appropriate view such as a TrackRendererSurfaceView.
        Parameters:
        space - The Space this callback applies to
        participant -
        track -
      • onParticipantTrackUnsubscribed

        default void onParticipantTrackUnsubscribed​(Space space,
                                                    Participant participant,
                                                    Track track)
        Called when we have been unsubscribed from a track.

        This means media is no longer available for this track.
        Parameters:
        space - The Space this callback applies to
        participant -
        track -
      • onParticipantTrackMuted

        default void onParticipantTrackMuted​(Space space,
                                             Participant participant,
                                             Track track)
        Called when the publishing participant for a track has muted the track.
        Parameters:
        space - The Space this callback applies to
        participant -
        track -
      • onParticipantTrackUnmuted

        default void onParticipantTrackUnmuted​(Space space,
                                               Participant participant,
                                               Track track)
        Called when the publishing participant for a track has unmuted the track.
        Parameters:
        space - The Space this callback applies to
        participant -
        track -
      • onParticipantCustomEvent

        default void onParticipantCustomEvent​(Space space,
                                              Participant participant,
                                              java.lang.String payload)
        Called when custom event is received.
        Parameters:
        space - The Space this callback applies to
        participant - , event dispatched by one of the remote participants in the space including this participant, participant that sends event also receive one via this callback.
        payload - , actual message.
      • onParticipantDisplayNameUpdated

        default void onParticipantDisplayNameUpdated​(Space space,
                                                     Participant participant,
                                                     java.lang.String displayName)
        Called when one of the participants in the space have changed is display name.
        Parameters:
        space - The Space this callback applies to
        participant - participant that changed it's display name
        displayName - new name to be used for participant.
      • onActiveSpeakers

        default void onActiveSpeakers​(Space space,
                                      java.util.Set<java.lang.String> activeSpeakerParticipantIds)
        Called when the set of active speakers has changed

        This is useful for features such as highlighting the speaker in a video call application. The provided Set is single use and you will receive all new Set instances with each update.
        Parameters:
        space - The Space this callback applies to
        activeSpeakerParticipantIds -
      • onBroadcastStateChanged

        default void onBroadcastStateChanged​(Space space,
                                             Space.BroadcastState broadcastState)
        Called when the Space BroadcastState has changed.

        This is useful for features such as showing a recording indicator in a video call application.
        Parameters:
        space - The Space this callback applies to
        broadcastState -
      • onError

        default void onError​(Space space,
                             MuxError error)
        Called when an error in the Space occurs.

        Note that this isn't limited to Space.Errors but also LocalParticipant.Errors etc. If it happened in the Space it'll land here.
        Parameters:
        space - The Space this callback applies to
        error - The MuxError
      • onMuxSpacesConnectionStateChanged

        default void onMuxSpacesConnectionStateChanged​(Space space,
                                                       SignalsConnection.State state)
        Called when the connection state changes.

        You shouldn't need to handle this. However, if a Space becomes disconnected for now the best thing to do is leave and re-enter. This is likely to change.
        Parameters:
        space - The Space this callback applies to
        state -