Closed ztdan4ik closed 6 years ago
I think, this happens because this function https://github.com/yaroslavche/phptdlib/blob/53f663c5a2b7fd77a55f53c692aca3c66303508d/include/TDLib/JsonClient.cpp#L17 works not the same as expected.
When you execute $client->query()
method, you expect receive response to your request. But now after BaseJsonClient::send(query);
receive first message. It's means that message in result can exists in queue before send
called. So, I think the best way is check if recieve()
return response before send()
, imho. This must be a function which handle all messages while BaseJsonClient::receive(0)
returns data. When receive(0)
is empty - then you can send your query and wait response.
I must rewrite handler for responses. As you can see right now it have dirty skip checking after receiving some type of data. It's like PoC. I will try to do my best when I have time
Hello. Please try compile with this PR: #13 Note that depends on one additional lib: nlohmann/json
The same response @type
in your case for now?
Hi there! Thanks for you replies.
You are right. TDLib must work async. Only few commands can be executed sync.
td_json_client_receive
method - one call = one response.
F.e. command setTdlibParameters will trigger more then 10 responses... It's mean td_json_client_receive
must be called many time to receive last response.
Finally we can understand that we need some endless loop with td_json_client_receive
inside and response handler there.
I think handler must be on php side, coz any developer need their own handler to solve personal tasks.
What I'm proposing here is to make only td_json_client_*
with void Client class on php-cpp. Rest of implementation make with php.
I have start to make php side - https://github.com/ztdan4ik/php-tdlib
What do you think about this? Can we cooperate our work?
make only td_jsonclient* with void Client class on php-cpp. Rest of implementation make with php.
It's already done with tdlib functions td_json_client_*
, so you can try write your own wrapper. Feel free to ask if need some changes =) Anyway I planning in future rewrite JsonClient
and it will be almost similar that you plan write =)
F.e. command setTdlibParameters will trigger more then 10 responses
And in my implementation for this moment responses to setTdlibParameters
can be received in another query
. Because if received empty response - loop breaks. Maybe it should wait some response @type
or some timeout before exit receiving responses loop. At this moment I have pretty shitty query
implementation =)
What do you think about this? Can we cooperate our work?
I think this is good thing at all. But I can't promise participating on your project due the time. Detailed answered with skype.
Hi there! Thanks for your extension.
I have a problem with
query
method. I trying to callgetChats
tdlib method and in result I see the object of updateFile@type.
What is wrong?Authorization state is Ready
See the code below
Result is
By the way after calling any methods returning an "EXCEPTION" text. You can see in on my screenshot above. Feel like it from here https://github.com/yaroslavche/phptdlib/blob/master/include/TDLib/JsonClient.cpp#L37
Thanks for your time!