Package-level declarations

Types

Link copied to clipboard
class ChatEngine(api: WidgetApi, connector: SocketConnector, store: SessionStore, appInfo: HatangAppInfo, logger: HatangLogger = HatangLogger.SILENT, preferredLocale: String? = null, backoff: Backoff = Backoff(), val backgroundCloseDelay: Duration = 10.seconds, val typingIdle: Duration = 3.seconds, val bootstrapRetry: Duration = 5.seconds, val openOnProactiveMessage: Boolean = true, clock: HatangClock = HatangClock.SYSTEM, scope: CoroutineScope? = null, dispatcher: CoroutineDispatcher = Dispatchers.Default)

The chat state machine: bootstrap → connect → ready → frames, plus every host-facing action. Pure Kotlin/JVM; the Android module wires storage, lifecycle and UI around it.

Link copied to clipboard

Where the engine is in its life.

Link copied to clipboard
data class ChatState(val phase: ChatPhase = ChatPhase.IDLE, val connection: HatangConnectionState = HatangConnectionState.DISCONNECTED, val config: SiteConfig? = null, val visitor: VisitorDto? = null, val conversation: ConversationSummary? = null, val timeline: Timeline = Timeline.EMPTY, val pending: List<PendingMessage> = emptyList(), val typingAgent: String? = null, val availability: Availability = Availability.OFFLINE, val unread: Int = 0, val locale: HatangLocale = HatangLocale.VI, val needsEmail: Boolean = false, val skippedEmail: Boolean = false, val rated: Int? = null, val transientError: HatangException? = null, val outdatedReason: String? = null, val visitorEmail: String? = null, val visitorName: String? = null, val loadingEarlier: Boolean = false, val visible: Boolean = false, val foreground: Boolean = true, val draft: String? = null)

Immutable snapshot of everything the UI renders (ChatEngine.state).

Link copied to clipboard

The chat screen was dismissed (emitted by the UI layer).

Link copied to clipboard

Socket connection state as exposed to hosts.

Link copied to clipboard
data class HatangConversationStatus(val conversationId: String, val status: ConversationStatus) : HatangEvent

The conversation's status changed.

Link copied to clipboard
data class HatangConversion(val kind: HatangConversionKind, val data: Map<String, Any?> = emptyMap()) : HatangEvent

A conversion the host may forward to its analytics.

Link copied to clipboard

Kinds of conversion the SDK reports.

Link copied to clipboard
sealed class HatangEvent

Something a host app may react to (ChatEngine.events).

Link copied to clipboard
data class HatangMessageReceived(val message: MessageDto) : HatangEvent

A message from the team, bot or system arrived.

Link copied to clipboard
data class HatangMessageSent(val message: MessageDto) : HatangEvent

A message from this visitor was stored (echo, possibly from another device).

Link copied to clipboard

The chat screen was shown (emitted by the UI layer).

Link copied to clipboard
data class HatangProtocolOutdated(val reason: String) : HatangEvent

The gateway no longer speaks this SDK's protocol version; ship an update.

Link copied to clipboard
data class HatangReady(val visitorId: String, val conversationId: String? = null) : HatangEvent

Bootstrapped and authenticated; the conversation (if any) is loaded.

Link copied to clipboard
data class HatangSession(val locale: HatangLocale, val visitorId: String? = null, val conversationId: String? = null, val isIdentified: Boolean = false, val email: String? = null, val name: String? = null)

A read-only view of the session for hosts.

Link copied to clipboard
data class HatangSessionChanged(val visitorId: String, val reason: HatangSessionChangeReason) : HatangEvent

The visitor identity behind this session changed.

Link copied to clipboard
Link copied to clipboard
data class PendingMessage(val clientId: String, val content: String, val createdAt: Instant, val attachments: List<String> = emptyList(), val upload: PendingUpload? = null, val failed: Boolean = false, val errorCode: String? = null)

An outgoing message that has no ack yet (or failed).

Link copied to clipboard
data class PendingUpload(val source: UploadSource, val progress: Double = 0.0, val uploadedId: String? = null)

The upload behind a pending attachment message.

Link copied to clipboard
data class Timeline(val items: List<TimelineItem> = emptyList(), val hasMore: Boolean = false, val lastSeq: Int = 0, val oldestSeq: Int = 0)

The loaded window of a conversation.

Link copied to clipboard
class UploadSource(val bytes: ByteArray, val name: String, val mimeType: String)

A file the visitor is sending: its bytes, name and MIME type. Built by the SDK's pickers (or by the host) and handed to ChatEngine.attach.

Properties

Link copied to clipboard

MIME types the gateway accepts (the same list as the server's upload allow-list).

Functions

Link copied to clipboard

MIME type for a file name, from its extension; null when the gateway would refuse it.