InteractKit

The primary entry point for the InteractKit SDK.

This class is used to initialise and manage the connection to the Monterosa Interaction Cloud, retrieve project and event data, and handle user authentication. Obtain an instance via InteractKit.default or InteractKit.from.

Content arrives through listeners rather than by polling. Register them on the Project and on each Event you care about, not on the kit itself:

val interactKit = InteractKit.from(Core.core("my-core"))

val listener = object : ProjectUpdateListener, EventUpdateListener {
override fun onEventPublished(project: Project, event: Event) { /* a new event went live */}
override fun onElementPublished(event: Event, element: Element) { /* render it */}
override fun onElementRevoked(event: Event, element: Element) { /* remove it */}
}

// getProject suspends: it returns the cached project or fetches one
val project = interactKit.getProject(context)
project.add(listener)

// Opening an event subscribes to its element channels; without this, nothing arrives live
val event = project.getEvents().first()
event.add(listener)
val elements = event.getElements()

Vote on an interactive element, and observe the connection while you do:

lifecycleScope.launch {
interactKit.connectionStateFlow.collect { state -> /* CONNECTED, CONNECTING, DISCONNECTED */}
}

try {
element.answer(0)
} catch (e: ElementVoteError) {
// closed element, vote limits, and so on
}

To attribute votes to a signed-in user, obtain a signature from IdentifyKit and pass it to login before voting. Use setStreamSyncDelay to hold messages back in step with a video broadcast.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Configuration for Interact. Holds, validates, requests configuration if needed

Link copied to clipboard
open override val connectionState: ConnectionState

The current state of the underlying real-time connection, as a snapshot value.

Link copied to clipboard
open override val connectionStateFlow: StateFlow<ConnectionState>

The current state of the underlying real-time connection, as a StateFlow. New collectors immediately receive the current state, then every subsequent transition.

Link copied to clipboard
open override var identifier: String
Link copied to clipboard

The currently active Project instance. This is null until a project is successfully retrieved via getProject.

Link copied to clipboard
open override val streamSyncDelay: Duration

The stream synchronisation delay currently in force, after clamping to the range the project permits. Starts at the project's default delay and changes only through setStreamSyncDelay.

Functions

Link copied to clipboard
open override fun getAllEvents(): ArrayList<Event>

Returns the list of all events currently available in the active project.

Link copied to clipboard
open suspend override fun getProject(context: Context): Project

Retrieves the main Project object.

Link copied to clipboard
open override fun getServerTime(): Long

Returns the current server time in milliseconds.

Link copied to clipboard
open fun load()
Link copied to clipboard
open override fun login(signature: Signature, complete: (success: Boolean) -> Unit)

Authenticates the user with a signed JWT.

Link copied to clipboard
open override fun logout()

Logs the current user out.

Link copied to clipboard
open override fun setStreamSyncDelay(delay: Duration)

Sets the delay for synchronizing real-time stream messages. This can be used to align SDK events with a live video broadcast.

Link copied to clipboard
open override fun vote(pollId: String, options: List<Int>, votes: List<Int>)

Casts a vote on a poll, delegating to the underlying real-time connection.