Package org.drinkless.tdlib
Class Client
- java.lang.Object
-
- org.drinkless.tdlib.Client
-
public final class Client extends Object
Main class for interaction with the TDLib.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceClient.ExceptionHandlerInterface for handler of exceptions thrown while invoking ResultHandler.static interfaceClient.ResultHandlerInterface for handler for results of queries to TDLib and incoming updates from TDLib.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Clientcreate(Client.ResultHandler updateHandler, Client.ExceptionHandler updateExceptionHandler, Client.ExceptionHandler defaultExceptionHandler)Creates new Client.static TdApi.Objectexecute(TdApi.Function query)Synchronously executes a TDLib request.protected voidfinalize()voidsend(TdApi.Function query, Client.ResultHandler resultHandler)Sends a request to the TDLib with an empty ExceptionHandler.voidsend(TdApi.Function query, Client.ResultHandler resultHandler, Client.ExceptionHandler exceptionHandler)Sends a request to the TDLib.
-
-
-
Method Detail
-
send
public void send(TdApi.Function query, Client.ResultHandler resultHandler, Client.ExceptionHandler exceptionHandler)
Sends a request to the TDLib.- Parameters:
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.- Throws:
NullPointerException- if query is null.
-
send
public void send(TdApi.Function query, Client.ResultHandler resultHandler)
Sends a request to the TDLib with an empty ExceptionHandler.- Parameters:
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.- Throws:
NullPointerException- if query is null.
-
execute
public static TdApi.Object execute(TdApi.Function query)
Synchronously executes a TDLib request. Only a few marked accordingly requests can be executed synchronously.- Parameters:
query- Object representing a query to the TDLib.- Returns:
- request result.
- Throws:
NullPointerException- if query is null.
-
create
public static Client create(Client.ResultHandler updateHandler, Client.ExceptionHandler updateExceptionHandler, Client.ExceptionHandler defaultExceptionHandler)
Creates new Client.- Parameters:
updateHandler- Handler for incoming updates.updateExceptionHandler- Handler for exceptions thrown from updateHandler. 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.- Returns:
- created Client
-
-