java.lang.Object
dev.voroby.springframework.telegram.client.Client

public final class Client extends Object
Main class for interaction with the TDLib.
  • 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

      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.
    • 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 the TelegramClient bean 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.