public final class Client
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Class and Description |
---|---|
static interface |
Client.ExceptionHandler
Interface for handler of exceptions thrown while invoking ResultHandler.
|
static interface |
Client.ResultHandler
Interface for handler for results of queries to TDLib and incoming updates from TDLib.
|
Modifier and Type | Method and Description |
---|---|
void |
bench(TdApi.Function query,
Client.ResultHandler handler,
int count)
Function for benchmarking number of queries per second which can handle the TDLib, ignore it.
|
void |
close()
Closes Client.
|
static Client |
create(Client.ResultHandler updatesHandler,
Client.ExceptionHandler updatesExceptionHandler,
Client.ExceptionHandler defaultExceptionHandler)
Creates new Client.
|
static TdApi.Object |
execute(TdApi.Function query)
Synchronously executes a TDLib request.
|
protected void |
finalize() |
void |
run()
Overridden method from Runnable, do not call it directly.
|
void |
send(TdApi.Function query,
Client.ResultHandler resultHandler)
Sends a request to the TDLib with an empty ExceptionHandler.
|
void |
send(TdApi.Function query,
Client.ResultHandler resultHandler,
Client.ExceptionHandler exceptionHandler)
Sends a request to the TDLib.
|
void |
setDefaultExceptionHandler(Client.ExceptionHandler defaultExceptionHandler)
Replaces default exception handler to be invoked on exceptions thrown from updatesHandler and all other ResultHandler.
|
static boolean |
setLogFilePath(java.lang.String filePath)
Deprecated.
As of TDLib 1.4.0 in favor of
TdApi.SetLogStream , to be removed in the future. |
static void |
setLogMaxFileSize(long maxFileSize)
Deprecated.
As of TDLib 1.4.0 in favor of
TdApi.SetLogStream , to be removed in the future. |
static void |
setLogVerbosityLevel(int newLogVerbosity)
Deprecated.
As of TDLib 1.4.0 in favor of
TdApi.SetLogVerbosityLevel , to be removed in the future. |
void |
setUpdatesHandler(Client.ResultHandler updatesHandler)
Replaces handler for incoming updates from the TDLib.
|
void |
setUpdatesHandler(Client.ResultHandler updatesHandler,
Client.ExceptionHandler exceptionHandler)
Replaces handler for incoming updates from the TDLib.
|
public void send(TdApi.Function query, Client.ResultHandler resultHandler, Client.ExceptionHandler exceptionHandler)
query
- Object representing a query to the TDLib.resultHandler
- Result handler with onResult method which will be called with result
of the query or with TdApi.Error as parameter. If it is null, nothing
will be called.exceptionHandler
- Exception handler with onException method which will be called on
exception thrown from resultHandler. If it is null, then
defaultExceptionHandler will be called.java.lang.NullPointerException
- if query is null.public void send(TdApi.Function query, Client.ResultHandler resultHandler)
query
- Object representing a query to the TDLib.resultHandler
- Result handler with onResult method which will be called with result
of the query or with TdApi.Error as parameter. If it is null, then
defaultExceptionHandler will be called.java.lang.NullPointerException
- if query is null.public static TdApi.Object execute(TdApi.Function query)
query
- Object representing a query to the TDLib.java.lang.NullPointerException
- if query is null.public void setUpdatesHandler(Client.ResultHandler updatesHandler, Client.ExceptionHandler exceptionHandler)
updatesHandler
- Handler with onResult method which will be called for every incoming
update from the TDLib.exceptionHandler
- Exception handler with onException method which will be called on
exception thrown from updatesHandler, if it is null, defaultExceptionHandler will be invoked.public void setUpdatesHandler(Client.ResultHandler updatesHandler)
updatesHandler
- Handler with onResult method which will be called for every incoming
update from the TDLib.public void setDefaultExceptionHandler(Client.ExceptionHandler defaultExceptionHandler)
defaultExceptionHandler
- Default exception handler. If null Exceptions are ignored.public void bench(TdApi.Function query, Client.ResultHandler handler, int count)
query
- Object representing a query to the TDLib.handler
- Result handler with onResult method which will be called with result
of the query or with TdApi.Error as parameter.count
- Number of times to repeat the query.java.lang.NullPointerException
- if query is null.public void run()
run
in interface java.lang.Runnable
public static Client create(Client.ResultHandler updatesHandler, Client.ExceptionHandler updatesExceptionHandler, Client.ExceptionHandler defaultExceptionHandler)
updatesHandler
- Handler for incoming updates.updatesExceptionHandler
- Handler for exceptions thrown from updatesHandler. If it is null, exceptions will be iggnored.defaultExceptionHandler
- Default handler for exceptions thrown from all ResultHandler. If it is null, exceptions will be iggnored.@Deprecated public static void setLogVerbosityLevel(int newLogVerbosity)
TdApi.SetLogVerbosityLevel
, to be removed in the future.newLogVerbosity
- New value of log verbosity. Must be non-negative.
Value 0 corresponds to android.util.Log.ASSERT,
value 1 corresponds to android.util.Log.ERROR,
value 2 corresponds to android.util.Log.WARNING,
value 3 corresponds to android.util.Log.INFO,
value 4 corresponds to android.util.Log.DEBUG,
value 5 corresponds to android.util.Log.VERBOSE,
value greater than 5 can be used to enable even more logging.
Default value of the log verbosity is 5.java.lang.IllegalArgumentException
- if newLogVerbosity is negative.@Deprecated public static boolean setLogFilePath(java.lang.String filePath)
TdApi.SetLogStream
, to be removed in the future.filePath
- Path to a file for writing TDLib internal log. Use an empty path to
switch back to logging to the Android Log.@Deprecated public static void setLogMaxFileSize(long maxFileSize)
TdApi.SetLogStream
, to be removed in the future.maxFileSize
- Maximum size of the file to where the internal TDLib log is written
before the file will be auto-rotated. Must be positive. Defaults to 10 MB.java.lang.IllegalArgumentException
- if max_file_size is non-positive.public void close()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable