Skip to content

Chat client life cycle

Marco Brescianini edited this page Nov 5, 2024 · 14 revisions

The following guide will teach you how to handle the conversation lifecycle for the 4.0 version, if you are looking for the 3.x version take a look a this guide instead.

Table of contents

Lifecycle

The lifecycle of the Kaleyra Video conversation begins after the configuration of the SDK. Once the SDK is configured, a conversation object will be created and it will be accessible from the KaleyraVideo singleton instance. When the SDK is told to start connecting, it will try to connect to the KaleyraVideo platform and the conversation object state will change reflecting the state of the connection with its services.

State changes

In order to be notified about conversation connection state changes, you can and you should subscribe as a subscriber to the conversation statePublisher. The following code listing will show you how to subscribe as subscriber of the conversation state publisher:

KaleyraVideo.instance.conversation?.statePublisher.removeDuplicates().receive(on: DispatchQueue.main).sink { state in
    debugPrint("Conversation state changed \(state)")
}.store(in: &subscriptions)

Note

Subscribers will be notified on a background queue unless you subscribe to a different scheduler

What's next

Clone this wiki locally