Closed culexjj closed 8 months ago
You print the value of the variable var
right after sending the request and long before it is initialized by the response handler.
Hello Levlam,
Thanks for your reply, I think I understand what you meant. it is related with the way the client interac with Telegram servers "Fully-asynchronous. Requests to TDLib don't block each other or anything else, responses will be sent when they are available."
I get it :-)
Thanks
Culex.
Hello
I'm having some issues managing the response of 'TdApi.SearchChatMessages'.
If I use this code it seems ok, I get the output printed on the console
...... private static FoundChatMessages var = new FoundChatMessages(); ...... private static void getChatMessages(final int limit, final long chat) {
client.send(new TdApi.SearchChatMessages(chat, "me imagino", null, 0, 0, 2, null, 0), new Client.ResultHandler() { @Override public void onResult(org.drinkless.tdlib.TdApi.Object object) { var = (FoundChatMessages) object; System.out.println ("\n" + var.toString()); } }); }
but I take the System.out.println ("\n" + var.toString()); sentence out like this, it doesn't print anything
private static void getChatMessages(final int limit, final long chat) {
client.send(new TdApi.SearchChatMessages(chat, "me imagino", null, 0, 0, 2, null, 0), new Client.ResultHandler() { @Override public void onResult(org.drinkless.tdlib.TdApi.Object object) { var = (FoundChatMessages) object; } }); System.out.println ("\n" + var.toString()); }
The most strange thing is if I debug the code it works fine, here you can see that var is not null.
It is clear to me that I'm doing something wrong but I don't understand this behavior.
Can you help me?
Thanks in advance
Culex