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 |
Public methods |
|
---|---|
abstract void |
broadcastToSecondaries(@NonNull byte[] bytes) Enqueues |
abstract @NonNull ListenableFuture<Void> |
broadcastToSecondariesFuture(@NonNull byte[] bytes) Java-compatible version of |
abstract void |
Ends the shared experience that this PrimarySession is currently leading. |
abstract @NonNull ListenableFuture<Void> |
Java-compatible version of |
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 |
abstract @NonNull List<@NonNull SessionRemoteConnection> |
Returns a list containing the |
abstract boolean |
Checks whether session discovery is currently enabled. |
abstract void |
removeSecondaryFromSession(@NonNull SessionParticipant secondary) Removes the given participant from this session. |
abstract @NonNull ListenableFuture<Void> |
Java-compatible version of |
Public fields
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 |
Throws | |
---|---|
com.google.ambient.crossdevice.sessions.SessionException com.google.ambient.crossdevice.sessions.SessionException |
if this |
broadcastToSecondariesFuture
abstract @NonNull ListenableFuture<Void> broadcastToSecondariesFuture(@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 |
destroyPrimarySessionAndStopSharingFuture
abstract @NonNull ListenableFuture<Void> destroyPrimarySessionAndStopSharingFuture()
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 |
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 |
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 |
getSecondaryRemoteConnections
abstract @NonNull List<@NonNull SessionRemoteConnection> getSecondaryRemoteConnections()
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 |
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 |
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 |
removeSecondaryFromSessionFuture
abstract @NonNull ListenableFuture<Void> removeSecondaryFromSessionFuture(@NonNull SessionParticipant secondary)
Java-compatible version of removeSecondaryFromSession
.