CoGuestStore

abstract class CoGuestStore

Live co-guest management related interfaces, managing co-guest application, invitation, acceptance, rejection and other operations between hosts and audience.

Overview

CoGuestStore Manages all co-guest related operations between hosts and audience, including application, invitation, acceptance and rejection processes. Co-guest feature enables real-time interaction between hosts and audience members through a seat-based system. CoGuestStore provides a comprehensive set of APIs to manage the entire co-guest lifecycle.

Core Features

  • Bidirectional Invitation: Hosts can invite audience members, and audience members can also apply to join

  • State Management: Real-time tracking of connected users, invitations and applications

  • Event-Driven Architecture: Provides separate event streams for host and guest roles

  • Timeout Handling: Built-in timeout mechanism for invitations and applications

Important: Always use the method CoGuestStore.create with a non-empty string liveID to create a CoGuestStore instance. Do not attempt to initialize directly. Co-guest state updates are delivered through the coGuestState publisher. Subscribe to it to receive real-time updates about connected users, invitations and applications.

Co-Guest Workflow

The following table shows a typical co-guest workflow:

StepRoleActionTriggered Event
1AudienceCall applyForSeatHostListener.onGuestApplicationReceived
2HostCall acceptApplicationGuestListener.onGuestApplicationResponded
3SystemUser connects to seatState updated through coGuestState publisher

Host-Initiated Flow

StepRoleActionTriggered Event
1HostCall inviteToSeatGuestListener.onHostInvitationReceived
2AudienceCall acceptInvitationHostListener.onHostInvitationResponded
3SystemUser connects to seatState updated through coGuestState publisher

Warning: If a co-guest request does not receive a response within the specified timeout, an event with NoResponseReason.timeout will be triggered. Always handle timeout scenarios in your UI.

Usage Example

// Create store instance
val store = CoGuestStore.create("live_room_123")

// Subscribe to state changes
lifecycleScope.launch {
store.coGuestState.connected.collect { connected ->
println("Connected users: ${connected.size}")
}
}

// Add host event listener (for hosts)
store.addHostListener(object : HostListener() {
override fun onGuestApplicationReceived(guestUser: LiveUserInfo) {
println("Received application from ${guestUser.userName}")
// Show accept/reject UI
}
override fun onHostInvitationResponded(isAccept: Boolean, guestUser: LiveUserInfo) {
println("Audience ${guestUser.userName} ${if (isAccept) "accepted" else "rejected"}")
}
})

// Host: Accept application
store.acceptApplication("user_456") { code, message ->
if (code == 0) {
println("Application accepted successfully")
}
}

Warning: Warning: If a co-guest request does not receive a response within the specified timeout, an event with NoResponseReason.timeout will be triggered. Always handle timeout scenarios in your UI.

Topics

Creating Instance

Observing State and Events

Guest Operations

Host Operations

Connection Control

See Also

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Co-guest related state data provided externally by CoGuestStore

Functions

Link copied to clipboard
abstract fun acceptApplication(userID: String?, completion: CompletionHandler?)

Accept seat application

Link copied to clipboard
abstract fun acceptInvitation(inviterID: String?, completion: CompletionHandler?)

Accept seat invitation

Link copied to clipboard
abstract fun addGuestListener(listener: GuestListener?)

Add guest-side event callback listener

Link copied to clipboard
abstract fun addHostListener(listener: HostListener?)

Add host-side event callback listener

Link copied to clipboard
abstract fun applyForSeat(seatIndex: Int, timeout: Int, extraInfo: String?, completion: CompletionHandler?)

Apply to go on seat

Link copied to clipboard
abstract fun cancelApplication(completion: CompletionHandler?)

Cancel a previously sent co-guest application. After calling this method, all hosts will be notified of the application cancellation.

Link copied to clipboard
abstract fun cancelInvitation(inviteeID: String?, completion: CompletionHandler?)

Cancel seat invitation

Link copied to clipboard
abstract fun disconnect(completion: CompletionHandler?)

Disconnect co-guest

Link copied to clipboard
abstract fun inviteToSeat(inviteeID: String?, seatIndex: Int, timeout: Int, extraInfo: String?, completion: CompletionHandler?)

Invite audience to seat

Link copied to clipboard
abstract fun rejectApplication(userID: String?, completion: CompletionHandler?)

Reject seat application

Link copied to clipboard
abstract fun rejectInvitation(inviterID: String?, completion: CompletionHandler?)

Reject seat invitation

Link copied to clipboard
abstract fun removeGuestListener(listener: GuestListener?)

Remove guest-side event callback listener

Link copied to clipboard
abstract fun removeHostListener(listener: HostListener?)

Remove host-side event callback listener