Class EasyClient

  • Direct Known Subclasses:
    BotClient, UserClient

    public class EasyClient
    extends java.lang.Object
    Interface for easy interaction with TDLib for bot, used to implement other clients such as BotClient and UserClient.
    • Field Detail

      • haveAuthorization

        protected volatile boolean haveAuthorization
    • Constructor Detail

      • EasyClient

        protected EasyClient​(AuthorizationHandler authorizationHandler)
        Creates a new EasyClient.
        Parameters:
        authorizationHandler - Callback to be implemented in the client to manage the authorization.
    • Method Detail

      • send

        protected long send​(TdApi.Function function)
        Send a request to tdlib without waiting for the result.
        Parameters:
        function - TDLib API function representing a request to TDLib.
        Returns:
        Request identifier. Responses to TDLib requests will have the same id as the corresponding request.
      • execute

        protected void execute​(TdApi.Function function,
                               ReceiveCallback receiveCallback,
                               ErrorCallback errorCallback)
        Send a request to tdlib and send the response to the callbacks.
        Parameters:
        function - TDLib API function representing a request to TDLib.
        receiveCallback - Interface of callback for receive incoming update or request response.
        errorCallback - Interface of callback for receive incoming error response.
      • execute

        protected Response execute​(TdApi.Function function)
        Send a request to tdlib, wait for the result and return the response.
        Parameters:
        function - TDLib API function representing a request to TDLib.
        Returns:
        A response to a request.
      • setUpdateCallback

        protected void setUpdateCallback​(ReceiveCallback receiveCallback)
        Set the default callback for general updates (no response to requests).
        Parameters:
        receiveCallback - Interface of callback for receive incoming update or request response.
      • setErrorCallback

        protected void setErrorCallback​(ErrorCallback errorCallback)
        Set the default callback for general error updates (no response to requests).
        Parameters:
        errorCallback - Interface of callback for receive incoming error response.
      • setCloseCallback

        protected void setCloseCallback​(CloseCallback closeCallback)
        Set the default callback for Tdlib closing notification.
        Parameters:
        closeCallback - Interface of callback for receive notification of closing Tdlib.
      • destroyBotClient

        protected void destroyBotClient()
        Destroys the client and TDLib instance.
      • authorizationHandler

        protected void authorizationHandler​(TdApi.UpdateAuthorizationState authorizationState)
        Manages the authorization state updates.
        Parameters:
        authorizationState - The status of the authorization.