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 interface`
  `Client.ExceptionHandler`
  Interface for handler of exceptions thrown while invoking ResultHandler.
  `static class`
  `Client.ExecutionException`
  Exception class thrown when TDLib error occurred while performing `execute(TdApi.Function)`.
  `static interface`
  `Client.LogMessageHandler`
  Interface for handler of messages that are added to the internal TDLib log.
  `static interface`
  `Client.ResultHandler`
  Interface for handler for results of queries to TDLib and incoming updates from TDLib.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Client`
  `create(Client.ResultHandler updateHandler, Client.ExceptionHandler updateExceptionHandler, Client.ExceptionHandler defaultExceptionHandler)`
  Creates new Client.
  `static <T extends TdApi.Object>
  T`
  `execute(TdApi.Function<T> query)`
  Synchronously executes a TDLib request.
  `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.
  `static void`
  `setLogMessageHandler(int maxVerbosityLevel, Client.LogMessageHandler logMessageHandler)`
  Sets the handler for messages that are added to the internal TDLib log.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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

  - ### 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.