Skip to main content

ChatConnectionController

ChatConnectionController is a controller class which allows to explicitly connect/disconnect the ChatClient and observe connection events.

public class ChatConnectionController: Controller, DelegateCallable, DataStoreProvider 

Inheritance

Controller, DelegateCallable, DataStoreProvider

Properties

connectionStatusPublisher

A publisher emitting a new value every time the connection status changes.

public var connectionStatusPublisher: AnyPublisher<ConnectionStatus, Never> 

observableObject

A wrapper object that exposes the controller variables in the form of ObservableObject to be used in SwiftUI.

public var observableObject: ObservableObject 

callbackQueue

public var callbackQueue: DispatchQueue = .main

client

The ChatClient instance this controller belongs to.

public let client: ChatClient

connectionStatus

The current connection status of the client.

public var connectionStatus: ConnectionStatus 

To observe changes of the connection status, set your class as a delegate of this controller or use the provided Combine publishers.

delegate

Set the delegate of ChatConnectionController to observe the changes in the system.

var delegate: ChatConnectionControllerDelegate? 

Methods

connect(completion:)

Connects the chat client the controller represents to the chat servers.

func connect(completion: ((Error?) -> Void)? = nil) 

When the connection is established, ChatClient starts receiving chat updates.

Parameters

  • completion: Called when the connection is established. If the connection fails, the completion is called with an error.

disconnect()

Disconnects the chat client the controller represents from the chat servers. No further updates from the servers are received.

func disconnect() 

setDelegate(_:)

Sets the provided object as a delegate of this controller.

func setDelegate<Delegate: ChatConnectionControllerDelegate>(_ delegate: Delegate?) 

Parameters

  • delegate: The object used as a delegate. It's referenced weakly, so you need to keep the object alive if you want keep receiving updates.

Did you find this page helpful?