Easy life :)
The client will handle most of the things for you:
- Create an authorization key
- Init the connection with app's info
- Ensure datacenter choice
- PHONE_MIGRATE_X and FILE_MIGRATE_X errors
- Easy download of files
To create a new instance, use
TelegramClient implements the
TelegramApi interface for more convenience, you have 1 java method for each method of Telegram's API.
You can also call
executeRpcQuery manually, and specify a
dcId where to execute the method if you have to.
For more convenience, you can use the method
queueMethodImmediate that is the same as
queueMethod but it'll subscribe automatically.
To avoid blocking your main client when uploading/downloading a file, it's strongly advised to use another connection, to do so, just use
getDownloaderClient() to get a new instance of a client for the same account.
client.downloadSync(inputLocation, size, partSize, outputStream);
inputLocationis an internal class of the library, it just contains a
TLAbsInputFileLocationand the target
dcIdto know where to download the file.
sizeis the size in bytes of the file to download.
partSizeoptional parameter specifying the size of each parts to download (default is 512 KB)
outputStreamstream to write in. A call to
flushis made every 5 parts downloaded. This stream can be a
FileOutputStreamor whatever you'd like :)
Or, if you're have multiple clients running, or you plan to open a new one
Updated less than a minute ago