Package org.drinkless.tdlib
Class Client
java.lang.Object
org.drinkless.tdlib.Client
Main class for interaction with the TDLib.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for handler of exceptions thrown while invoking ResultHandler.static classException class thrown when TDLib error occurred while performingexecute(TdApi.Function).static interfaceInterface for handler of messages that are added to the internal TDLib log.static interfaceInterface for handler for results of queries to TDLib and incoming updates from TDLib. -
Method Summary
Modifier and TypeMethodDescriptionstatic Clientcreate(Client.ResultHandler updateHandler, Client.ExceptionHandler updateExceptionHandler, Client.ExceptionHandler defaultExceptionHandler) Creates new Client.static <T extends TdApi.Object>
Texecute(TdApi.Function<T> query) Synchronously executes a TDLib request.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.static voidsetLogMessageHandler(int maxVerbosityLevel, Client.LogMessageHandler logMessageHandler) Sets the handler for messages that are added to the internal TDLib log.
-
Method Details
-
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.
-
send
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.
-
execute
public static <T extends TdApi.Object> T execute(TdApi.Function<T> query) throws Client.ExecutionException Synchronously executes a TDLib request. Only a few marked accordingly requests can be executed synchronously.- Type Parameters:
T- Automatically deduced return type of the query.- Parameters:
query- Object representing a query to the TDLib.- Returns:
- request result.
- Throws:
Client.ExecutionException- if query execution fails.
-
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 ignored.defaultExceptionHandler- Default handler for exceptions thrown from all ResultHandler. If it is null, exceptions will be ignored.- Returns:
- created Client
- Throws:
TelegramClientConfigurationException- if a Client instance has already been created for this JVM process. If you want to create the instance again, you should close the running instance and get AuthorizationStateClosed. After this, a new instance of theTelegramClientbean must be registered in context.
-
setLogMessageHandler
public static void setLogMessageHandler(int maxVerbosityLevel, Client.LogMessageHandler logMessageHandler) Sets the handler for messages that are added to the internal TDLib log. None of the TDLib methods can be called from the callback.- Parameters:
maxVerbosityLevel- The maximum verbosity level of messages for which the callback will be called.logMessageHandler- Handler for messages that are added to the internal TDLib log. Pass null to remove the handler.
-