AddonClient

@PublicApi
public interface AddonClient



Primary interface for starting and stopping an add-on session.

Note: Only one session may be active at a time, else the ListenableFuture returned by begin will resolve with an . A session may end on its own (e.g. the user left the meeting) and call onSessionEnded, or the session may be terminated by calling endSession.

Sample usage:

class AwesomeAddonSessionHandler implements AddonSessionHandler {}

class AwesomeCoWatchingHandler implements CoWatchingHandler {}

public void registerStatusListener() {
  AddonClient meetClient = AddonClientFactory.getClient();
  meetClient.registerMeetingStatusListener(
      appContext,
      meetingStatus -> {
        switch (meetingStatus.status()) {
          case NO_MEETING:
            // User is not in a meeting currently.
            break;
          case MEETING:
            // User is in a meeting, check if they want to start an add-on session.
            showStartAddonSessionDialog();
            break;
          case ADDON_SESSION:
            // User is in a meeting that already hosts an add-on session, check if they want
            // to join the ongoing session.
            showJoinAddonSessionDialog();
            break;
        }
      },
      Optional.empty());
}

public ListenableFuture<AddonClient> initialSetup() {
  AddonClient meetClient = AddonClientFactory.getClient();
  return meetClient
      .newSessionBuilder(appContext, new AwesomeAddonSessionHandler())
      .withCoWatching(new AwesomeCoWatchingHandler())
      .begin();
}

Summary

Nested types

Represents a failure event occurred before, during or after an add-on session.

Public methods

abstract AddonSession.Builder

Returns a builder for a new add-on session.

abstract void
notifyAddonFailureEvent(
    Context appContext,
    AddonClient.AddonFailureEventType failureEventType
)

Notifies Meet of an add-on failure event.

abstract void
registerMeetingStatusListener(
    Context appContext,
    MeetingStatusListener listener,
    Optional<Handler> handler
)

Registers a listener to be notified of changes in the status of meetings and add-on sessions.

abstract void

Unregisters an active listener for MeetingStatus changes.

Public methods

newSessionBuilder

abstract AddonSession.Builder newSessionBuilder(AddonSessionHandler handler)

Returns a builder for a new add-on session. The session will only begin once begin is called.

To begin a session, first chain withCoWatching, withCoDoing or both onto this builder.

Sample usage:

ListenableFuture<AddonSession> session = meetClient
    .newSessionBuilder(appContext, new AwesomeAddonSessionHandler())
    .withCoWatching(new AwesomeCoWatchingHandler())
    .withCoDoing(new AwesomeCoDoingHandler())
    .begin();
To leverage the participant metadata functionality, call withParticipantMetadata on the builder chain to specify the initial state and register a listener for other participants. For example:
ListenableFuture<AddonSession> session = meetClient
    .newSessionBuilder(new AwesomeAddonSessionHandler())
    .withCoWatching(new AwesomeCoWatchingHandler())
    .withParticipantMetadata(new AwesomeMetadataHandler(), myMetadataBytes)
    .begin(appContext);
See begin for more details on how a session is started.
Parameters
AddonSessionHandler handler

callbacks that apply to all add-on sessions

Returns
AddonSession.Builder

a builder for a new AddonSession instance

Throws
java.lang.NullPointerException

if any of the provided arguments are null

notifyAddonFailureEvent

abstract void notifyAddonFailureEvent(
    Context appContext,
    AddonClient.AddonFailureEventType failureEventType
)

Notifies Meet of an add-on failure event.

Parameters
Context appContext

the getApplicationContext value of the application that is using the Meet Add-on's SDK

AddonClient.AddonFailureEventType failureEventType

the type of failure event encountered before, during or after a live sharing session

Throws
java.lang.NullPointerException

if any of the provided arguments are null

registerMeetingStatusListener

abstract void registerMeetingStatusListener(
    Context appContext,
    MeetingStatusListener listener,
    Optional<Handler> handler
)

Registers a listener to be notified of changes in the status of meetings and add-on sessions.

The registered listener will be notified due to one of the following statuses:

  • MEETING - There is an active meeting in the Meet app
  • ADDON_SESSION - There is an active add-on session. This is only possible if there is also an active meeting.
  • NO_MEETING - No meeting or add-on session
Parameters
Context appContext

the getApplicationContext value of the application that is using the Meet Add-on's SDK

MeetingStatusListener listener

the MeetingStatusListener to be notified of status changes

Optional<Handler> handler

an Optional of Handler for asynchronous execution. If one is not supplied, resulting logic may run on the UI thread.

Throws
java.lang.IllegalStateException

If this method is called before calling unregisterMeetingStatusListener for an already registered listener

unregisterMeetingStatusListener

abstract void unregisterMeetingStatusListener(Context appContext)

Unregisters an active listener for MeetingStatus changes.

Parameters
Context appContext

the getApplicationContext value of the application that is using the Meet Add-on's SDK

Throws
java.lang.IllegalStateException

If this method is called before calling registerMeetingStatusListener.