How TDLibClientManager and TDLibClient work together
mainTDLibKit uses a two-tier architecture for managing connections:
TDLibClientManager: A singleton-like manager that handles the underlyingtd_receiveloop. Crucially, you must create only oneTDLibClientManagerinstance, astd_receivecan only be called from a single thread. The manager automatically polls for updates.TDLibClient: Created via the manager. Each client instance represents a specific connection/session and provides the interface for sending requests and receiving updates.
Updates are handled via a closure provided when creating the client.
import TDLibKit
// 1. Create the single manager
let manager = TDLibClientManager()
// 2. Create a client and handle updates
let client = manager.createClient(updateHandler: { data, client in
// Handle updates here
})