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.
Properties
Configuration for Interact. Holds, validates, requests configuration if needed
The current state of the underlying real-time connection, as a snapshot value.
The current state of the underlying real-time connection, as a StateFlow. New collectors immediately receive the current state, then every subsequent transition.
The currently active Project instance. This is null until a project is successfully retrieved via getProject.
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
Returns the list of all events currently available in the active project.
Retrieves the main Project object.
Returns the current server time in milliseconds.
Sets the delay for synchronizing real-time stream messages. This can be used to align SDK events with a live video broadcast.