Coordinator
public class Coordinator
The Coordinator
handles update, functions, downloads and the authorization- and connection state.
-
The
TDJsonClient
instance.Declaration
Swift
public private(set) var client: TDJsonClient
-
The stream of authorization stats.
waitTdlibParameters
andwaitEncryptionKey
are already handled by theCoordinator
and should be ignored.Declaration
Swift
public let authorizationState: Stream<LoadingEvent<AuthorizationState>>
-
The stream of the current connection state.
Declaration
Swift
public let connectionState: Stream<LoadingEvent<ConnectionState>>
-
The stream of all updates.
-
Undocumented
Declaration
Swift
public let floodStream: FloodStream
-
Initalizes a new
Coordinator
instance.Declaration
Swift
public init(client: TDJsonClient = TDJsonClient(), parameters: TdlibParameters, encryptionKey: Data = Data(repeating: 123, count: 64))
Parameters
client
The
TDJsonClient
used for all communcation withtdlib
(default is newTDJsonClient
).parameters
The parameters used to configure
tdlib
.encryptionKey
The encryption key for the local database.
-
Initalizes a new
Coordinator
instance.Declaration
Swift
public convenience init(client: TDJsonClient = TDJsonClient(), apiId: Int32, apiHash: String, useTestDc: Bool = false, encryptionKey: Data = Data(repeating: 123, count: 64))
Parameters
client
The
TDJsonClient
used for all communcation withtdlib
(default is newTDJsonClient
).apiId
The application identifier for Telegram API access, which can be obtained at https://my.telegram.org
apiHash
The application identifier hash for Telegram API access, which can be obtained at https://my.telegram.org
useTestDc
If set to true, the Telegram test environment will be used instead of the production environment
encryptionKey
The encryption key for the local database.
-
Undocumented
Declaration
Swift
public func recreateClient(_ client: TDJsonClient = TDJsonClient())
-
Downloads a new file.
Declaration
Swift
public func download(file: File, priority: Int32 = 32) -> Stream<DownloadEvent<File>>
Parameters
file
The file to download.
priority
A priority between 0 and 32 (default 32).
Return Value
A stream of the download events of the given file.
-
Send the request to
tdlib
.Declaration
Swift
public func send<F>(_ function: F) -> Promise<F.Result> where F : TDFunction
Parameters
function
A
TDFunction
.Return Value
A promise of the result of the function.