ChatInstanceProvider

ChatRepository owns and maintains the chat object and its state.

Parameters

configuration

Initial Sdk Configuration to use.

authorization

Initial authorization to use.

userName

Initial user name to use.

developmentMode

True if in development mode to get extra logging.

deviceTokenProvider

Provider of device tokens for push messages, default implementation will disable push notifications.

logger

The Logger used by the SDK, default is no-op implementation.

customerId

Optional customerId of the user.

chatBuilderProvider

INTERNAL USAGE ONLY Provides ChatBuilder. For internal testing usage only.

dispatcher

Coroutine dispatcher used for background operations, defaults to Dispatchers.IO.

Types

Link copied to clipboard

Authentication scope for configuring identity and token-related settings.

Link copied to clipboard
object Companion
Link copied to clipboard

Configuration scope used to reconfigure and restart the chat session.

Link copied to clipboard
fun interface DeviceTokenProvider

Defines provider of device token for push notifications, typically this will be Firebase.messaging.token.

Link copied to clipboard
interface Listener

those interested in ChatInstanceProvider updates.

Properties

Link copied to clipboard

Current authorization.

Link copied to clipboard
var chat: Chat?

Current chat object.

Link copied to clipboard

Current chat state.

Link copied to clipboard

Current configuration.

Link copied to clipboard

Current optional customerId.

Link copied to clipboard

Current developmentMode state. If true, additional debugging is provided

Link copied to clipboard
Link copied to clipboard
open override val identity: Logger
Link copied to clipboard

Current Logger.

Link copied to clipboard
open override val scope: String
Link copied to clipboard

Current optional token delegate listener for implicit OAuth flow.

Link copied to clipboard

Current user name.

Functions

Link copied to clipboard

Add a listener to receive notifications of chat and state changes.

Link copied to clipboard
fun cancel()

Cancel any pending prepare or connect action and return the state to an appropriate starting point.

Link copied to clipboard

Close any connected chat web sockets.

Link copied to clipboard
suspend fun closeSuspending()

Coroutine-native equivalent of close -- prefer this from a coroutine context.

Link copied to clipboard
suspend fun configure(context: Context, actions: ChatInstanceProvider.ConfigurationScope.() -> Unit)

Update the configuration of chat.

Link copied to clipboard
fun connect()

Connect the chat web socket so chat functions are available.

Link copied to clipboard
open override fun log(level: Level, message: String, throwable: Throwable?)
Link copied to clipboard
open override fun onChatRuntimeException(exception: RuntimeChatException)

Method is invoked when Chat instance encounters possible exception in a background process. Application should handle these exceptions according to the description of each RuntimeChatException. Some of these exceptions can indicate issues during transfer of messages while others may indicate that further interactions with Chat will be ignored.

Link copied to clipboard
open override fun onConnected()

Method is invoked when chat instance is connected and ready to send/receive messages, events or actions. This happens once initial connection is established or after Chat.reconnect is called.

Link copied to clipboard
open override fun onConnecting()

Method is invoked when the application initiates connection to chat session or if the session was lost and chat attempts automatically to reconnect. Chat should be considered temporarily unavailable until onConnected is invoked.

Link copied to clipboard
open override fun onReady()

Method is invoked when chat instance has finished performing background tasks after connection was established.

Link copied to clipboard
open override fun onUnexpectedDisconnect()

Method is invoked when chat session is unexpectedly lost during initial connection, or if the initial connection was established, but then lost and retry mechanism has been exhausted without success.

Link copied to clipboard
fun prepare(context: Context, newConfig: SocketFactoryConfiguration? = null)

Reestablish a chat connection if one does not currently exist.

Link copied to clipboard

Remove a listener no longer concerned with chat and state changes.

Link copied to clipboard

Set custom values on the current chat instance.

Link copied to clipboard

Sets or clears the TokenDelegateListener for the implicit OAuth flow.

Link copied to clipboard

Sets UserName which will be used during creation of Chat instance and will apply it to current instance of Chat, if it exists. The username will be applied only if the chat channel configuration allows it.

Link copied to clipboard
suspend fun signOut(): Unit?

Sign out/terminate the chat connection and clear any saved credentials.