Package it.ernytech.tdbot
Class EasyClient
- java.lang.Object
-
- it.ernytech.tdbot.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 Summary
Fields Modifier and Type Field Description protected boolean
haveAuthorization
-
Constructor Summary
Constructors Modifier Constructor Description protected
EasyClient(AuthorizationHandler authorizationHandler)
Creates a new EasyClient.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
authorizationHandler(TdApi.UpdateAuthorizationState authorizationState)
Manages the authorization state updates.protected void
destroyBotClient()
Destroys the client and TDLib instance.protected Response
execute(TdApi.Function function)
Send a request to tdlib, wait for the result and return the response.protected void
execute(TdApi.Function function, it.ernytech.tdlib.utils.ReceiveCallback receiveCallback, it.ernytech.tdlib.utils.ErrorCallback errorCallback)
Send a request to tdlib and send the response to the callbacks.protected long
send(TdApi.Function function)
Send a request to tdlib without waiting for the result.protected void
setCloseCallback(it.ernytech.tdlib.utils.CloseCallback closeCallback)
Set the default callback for Tdlib closing notification.protected void
setErrorCallback(it.ernytech.tdlib.utils.ErrorCallback errorCallback)
Set the default callback for general error updates (no response to requests).protected void
setUpdateCallback(it.ernytech.tdlib.utils.ReceiveCallback receiveCallback)
Set the default callback for general updates (no response to requests).
-
-
-
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, it.ernytech.tdlib.utils.ReceiveCallback receiveCallback, it.ernytech.tdlib.utils.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(it.ernytech.tdlib.utils.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(it.ernytech.tdlib.utils.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(it.ernytech.tdlib.utils.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.
-
-