2018-12-31 20:04:05 +01:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#include "td/telegram/td_json_client.h"
|
|
|
|
|
2021-05-18 03:35:36 +02:00
|
|
|
#include "td/telegram/Client.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/ClientJson.h"
|
|
|
|
|
|
|
|
#include "td/utils/Slice.h"
|
|
|
|
|
|
|
|
void *td_json_client_create() {
|
|
|
|
return new td::ClientJson();
|
|
|
|
}
|
|
|
|
|
|
|
|
void td_json_client_destroy(void *client) {
|
|
|
|
delete static_cast<td::ClientJson *>(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
void td_json_client_send(void *client, const char *request) {
|
2018-09-21 15:41:22 +02:00
|
|
|
static_cast<td::ClientJson *>(client)->send(td::Slice(request == nullptr ? "" : request));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *td_json_client_receive(void *client, double timeout) {
|
2020-10-05 14:48:37 +02:00
|
|
|
return static_cast<td::ClientJson *>(client)->receive(timeout);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *td_json_client_execute(void *client, const char *request) {
|
2020-10-05 14:48:37 +02:00
|
|
|
return td::ClientJson::execute(td::Slice(request == nullptr ? "" : request));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2020-10-05 15:08:07 +02:00
|
|
|
|
2020-11-14 23:13:11 +01:00
|
|
|
int td_create_client_id() {
|
|
|
|
return td::json_create_client_id();
|
2020-10-05 15:08:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void td_send(int client_id, const char *request) {
|
2020-11-12 12:45:18 +01:00
|
|
|
td::json_send(client_id, td::Slice(request == nullptr ? "" : request));
|
2020-10-05 15:08:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *td_receive(double timeout) {
|
2020-11-12 12:45:18 +01:00
|
|
|
return td::json_receive(timeout);
|
2020-10-05 15:08:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *td_execute(const char *request) {
|
2020-11-12 12:45:18 +01:00
|
|
|
return td::json_execute(td::Slice(request == nullptr ? "" : request));
|
2020-10-05 15:08:07 +02:00
|
|
|
}
|
2021-05-18 03:35:36 +02:00
|
|
|
|
|
|
|
void td_set_log_message_callback(int max_verbosity_level, td_log_message_callback_ptr callback) {
|
|
|
|
td::ClientManager::set_log_message_callback(max_verbosity_level, callback);
|
|
|
|
}
|