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 functions |
|
---|---|
suspend Unit |
broadcastToSecondaries(bytes: ByteArray) Enqueues |
ListenableFuture<Void?> |
Java-compatible version of |
suspend Unit |
Ends the shared experience that this PrimarySession is currently leading. |
ListenableFuture<Void?> |
Java-compatible version of |
Unit |
Disallows new participants to find and join the session. |
Unit |
Enables new participants to find and join the session. |
SessionRemoteConnection |
Returns the |
List<SessionRemoteConnection> |
Returns a list containing the |
Boolean |
Checks whether session discovery is currently enabled. |
suspend Unit |
removeSecondaryFromSession(secondary: SessionParticipant) Removes the given participant from this session. |
ListenableFuture<Void?> |
removeSecondaryFromSessionFuture(secondary: SessionParticipant) Java-compatible version of |
Public properties |
|
---|---|
SessionId |
The |
Public functions
broadcastToSecondaries
suspend fun broadcastToSecondaries(bytes: ByteArray): Unit
Enqueues bytes
to be sent to all connected secondaries on their associated SessionRemoteConnection
.
Parameters | |
---|---|
bytes: ByteArray |
The bytes to be sent across the |
Throws | |
---|---|
com.google.ambient.crossdevice.sessions.SessionException: com.google.ambient.crossdevice.sessions.SessionException |
if this |
broadcastToSecondariesFuture
fun broadcastToSecondariesFuture(bytes: ByteArray): ListenableFuture<Void?>
Java-compatible version of broadcastToSecondaries
.
destroyPrimarySessionAndStopSharing
suspend fun destroyPrimarySessionAndStopSharing(): Unit
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
fun destroyPrimarySessionAndStopSharingFuture(): ListenableFuture<Void?>
Java-compatible version of destroyPrimarySessionAndStopSharing
.
disableSessionDiscovery
fun disableSessionDiscovery(): Unit
Disallows new participants to find and join the session.
Throws | |
---|---|
com.google.ambient.crossdevice.sessions.SessionException: com.google.ambient.crossdevice.sessions.SessionException |
This |
enableSessionDiscovery
fun enableSessionDiscovery(): Unit
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
fun getSecondaryRemoteConnectionForParticipant(
secondary: SessionParticipant
): SessionRemoteConnection
Returns the SessionRemoteConnection
for secondary
.
Throws | |
---|---|
com.google.ambient.crossdevice.sessions.SessionException: com.google.ambient.crossdevice.sessions.SessionException |
if this |
getSecondaryRemoteConnections
fun getSecondaryRemoteConnections(): List<SessionRemoteConnection>
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
fun isSessionDiscoveryEnabled(): Boolean
Checks whether session discovery is currently enabled.
Throws | |
---|---|
com.google.ambient.crossdevice.sessions.SessionException: com.google.ambient.crossdevice.sessions.SessionException |
This |
removeSecondaryFromSession
suspend fun removeSecondaryFromSession(secondary: SessionParticipant): Unit
Removes the given participant from this session. On the secondary side, the secondary will be notified with SecondarySessionStateCallback.onSecondarySessionCleanup
.
Parameters | |
---|---|
secondary: SessionParticipant |
The participant to remove. |
Throws | |
---|---|
com.google.ambient.crossdevice.sessions.SessionException: com.google.ambient.crossdevice.sessions.SessionException |
This |
removeSecondaryFromSessionFuture
fun removeSecondaryFromSessionFuture(secondary: SessionParticipant): ListenableFuture<Void?>
Java-compatible version of removeSecondaryFromSession
.