PrimarySession


@RequiresApi(value = 26) interface PrimarySession


When a Session becomes shared with one or more devices, this interface represents the Primary device (the Session owner).

Summary

Public fields

abstract @NonNull SessionId

The SessionId this PrimarySession belongs to.

Public methods

abstract void

Enqueues bytes to be sent to all connected secondaries on their associated SessionRemoteConnection.

abstract @NonNull ListenableFuture<Void>

Java-compatible version of broadcastToSecondaries.

abstract void

Ends the shared experience that this PrimarySession is currently leading.

abstract @NonNull ListenableFuture<Void>

Java-compatible version of destroyPrimarySessionAndStopSharing.

abstract void

Disallows new participants to find and join the session.

abstract void

Enables new participants to find and join the session.

abstract @NonNull SessionRemoteConnection

Returns the SessionRemoteConnection for secondary.

abstract @NonNull List<@NonNull SessionRemoteConnection>

Returns a list containing the SessionRemoteConnection instances for all secondaries related to this session.

abstract boolean

Checks whether session discovery is currently enabled.

abstract void

Removes the given participant from this session.

abstract @NonNull ListenableFuture<Void>

Java-compatible version of removeSecondaryFromSession.

Public fields

sessionId

abstract @NonNull SessionId sessionId

The SessionId this PrimarySession belongs to.

Public methods

broadcastToSecondaries

abstract void broadcastToSecondaries(@NonNull byte[] bytes)

Enqueues bytes to be sent to all connected secondaries on their associated SessionRemoteConnection.

Parameters
@NonNull byte[] bytes

The bytes to be sent across the SessionRemoteConnection.

Throws
com.google.ambient.crossdevice.sessions.SessionException com.google.ambient.crossdevice.sessions.SessionException

if this PrimarySession is no longer valid.

broadcastToSecondariesFuture

abstract @NonNull ListenableFuture<VoidbroadcastToSecondariesFuture(@NonNull byte[] bytes)

Java-compatible version of broadcastToSecondaries.

destroyPrimarySessionAndStopSharing

abstract void destroyPrimarySessionAndStopSharing()

Ends the shared experience that this PrimarySession is currently leading. Once destroyPrimarySessionAndStopSharing is called, all other methods will throw SessionException when called.

On the secondary side, each secondary will be notified with SecondarySessionStateCallback.onSecondarySessionCleanup.

Throws
com.google.ambient.crossdevice.sessions.SessionException com.google.ambient.crossdevice.sessions.SessionException

This PrimarySession is no longer valid.

destroyPrimarySessionAndStopSharingFuture

abstract @NonNull ListenableFuture<VoiddestroyPrimarySessionAndStopSharingFuture()

Java-compatible version of destroyPrimarySessionAndStopSharing.

disableSessionDiscovery

abstract void disableSessionDiscovery()

Disallows new participants to find and join the session.

Throws
com.google.ambient.crossdevice.sessions.SessionException com.google.ambient.crossdevice.sessions.SessionException

This PrimarySession is no longer valid.

enableSessionDiscovery

abstract void enableSessionDiscovery()

Enables new participants to find and join the session. This PrimarySession is notified of new participants joining the session via PrimarySessionStateCallback.onParticipantJoined. New participants are disabled by default.

Throws
com.google.ambient.crossdevice.sessions.SessionException com.google.ambient.crossdevice.sessions.SessionException

This PrimarySession is no longer valid.

getSecondaryRemoteConnectionForParticipant

abstract @NonNull SessionRemoteConnection getSecondaryRemoteConnectionForParticipant(
    @NonNull SessionParticipant secondary
)

Returns the SessionRemoteConnection for secondary.

Throws
com.google.ambient.crossdevice.sessions.SessionException com.google.ambient.crossdevice.sessions.SessionException

if this PrimarySession is no longer valid or the secondary is not connected.

getSecondaryRemoteConnections

abstract @NonNull List<@NonNull SessionRemoteConnectiongetSecondaryRemoteConnections()

Returns a list containing the SessionRemoteConnection instances for all secondaries related to this session.

Throws
com.google.ambient.crossdevice.sessions.SessionException com.google.ambient.crossdevice.sessions.SessionException

if this PrimarySession is no longer valid.

isSessionDiscoveryEnabled

abstract boolean isSessionDiscoveryEnabled()

Checks whether session discovery is currently enabled.

Throws
com.google.ambient.crossdevice.sessions.SessionException com.google.ambient.crossdevice.sessions.SessionException

This PrimarySession is no longer valid.

removeSecondaryFromSession

abstract void removeSecondaryFromSession(@NonNull SessionParticipant secondary)

Removes the given participant from this session. On the secondary side, the secondary will be notified with SecondarySessionStateCallback.onSecondarySessionCleanup.

Parameters
@NonNull SessionParticipant secondary

The participant to remove.

Throws
com.google.ambient.crossdevice.sessions.SessionException com.google.ambient.crossdevice.sessions.SessionException

This PrimarySession is no longer valid.

removeSecondaryFromSessionFuture

abstract @NonNull ListenableFuture<VoidremoveSecondaryFromSessionFuture(@NonNull SessionParticipant secondary)

Java-compatible version of removeSecondaryFromSession.