Old native C++ interface for interaction with TDLib to be removed in TDLib 2.0.0.
The TDLib instance is created for the lifetime of the Client object. Requests to TDLib can be sent using the Client::send method from any thread. New updates and responses to requests can be received using the Client::receive method from any thread, this function must not be called simultaneously from two different threads. Also, note that all updates and responses to requests should be applied in the same order as they were received, to ensure consistency. Given this information, it's advisable to call this function from a dedicated thread. Some service TDLib requests can be executed synchronously from any thread using the Client::execute method.
General pattern of usage:
std::shared_ptr<td::Client> client = std::make_shared<td::Client>();
const double WAIT_TIMEOUT = 10.0;
bool is_closed = false;
while (!is_closed) {
auto response = client->
receive(WAIT_TIMEOUT);
if (response.object == nullptr) {
continue;
}
if (response.id == 0) {
} else {
}
}