TelegramClient
Telegram Client class
Method Summary
Public Methods | ||
public |
authenticate(config: Object): Promise<TelegramClient> Creates an authKey and setups an encrypted channel in the client with this new key. |
|
public |
Entry method to all the API calls |
|
public |
Negotiates a new AuthKey with the server |
|
public |
createEncryptedChannel(authKey: Object, options: Object): * Creates an encrypted channel with a previously created {AuthKey} |
|
public |
Creates a plain-text channel to make API calls. |
|
public |
restoreFromConfig(config: Object) Restores an encrypted channel in this client from a config object. |
|
public |
setChannel(channel: RcpChannel | EncryptedRpcChannel) A channel to execute API calls. |
|
public |
setConnection(connection: Object) Set the connection to be used as the transport for API calls in this client |
|
public |
setup(config: *): * Top-level method to setup the client. |
Public Methods
public authenticate(config: Object): Promise<TelegramClient> source
Creates an authKey and setups an encrypted channel in the client with this new key.
Params:
Name | Type | Attribute | Description |
config | Object | Configuration passed in to the EncryptedRpcChannel |
public createEncryptedChannel(authKey: Object, options: Object): * source
Creates an encrypted channel with a previously created {AuthKey}
public createUnencryptedChannel(): * source
Creates a plain-text channel to make API calls. Used on the initial calls to create an authentication key
Return:
* |
public restoreFromConfig(config: Object) source
Restores an encrypted channel in this client from a config object. A previously created AuthKey must be present in the config.
Params:
Name | Type | Attribute | Description |
config | Object | Configuration passed in to the EncryptedRpcChannel |
public setChannel(channel: RcpChannel | EncryptedRpcChannel) source
A channel to execute API calls. Usually created through one of these methods:
Client#createUnencryptedChannel Client#createEncryptedChannel
Params:
Name | Type | Attribute | Description |
channel | RcpChannel | EncryptedRpcChannel |
public setConnection(connection: Object) source
Set the connection to be used as the transport for API calls in this client
Params:
Name | Type | Attribute | Description |
connection | Object |
public setup(config: *): * source
Top-level method to setup the client. Give it a configuration and the client will handle the creation of an encrypted channel.
Don't forget to set a connection in the client before starting the setup!
Params:
Name | Type | Attribute | Description |
config | * |
Return:
* |