aboutsummaryrefslogtreecommitdiffhomepage
path: root/td/telegram/td_json_client.cpp
diff options
context:
space:
mode:
authorArseny Smirnov <arseny30@gmail.com>2018-12-31 22:04:05 +0300
committerArseny Smirnov <arseny30@gmail.com>2017-12-31 23:08:40 +0300
commit71d03f39c364367a8a7c51f783a41099297de826 (patch)
tree4c0c57f9ddb87f46d58192e1ebfd2c40f6d2c315 /td/telegram/td_json_client.cpp
Project import generated by Copybara.
GitOrigin-RevId: 318483224ad6164d9966f731d60cde37039bb2d4
Diffstat (limited to 'td/telegram/td_json_client.cpp')
-rw-r--r--td/telegram/td_json_client.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/td/telegram/td_json_client.cpp b/td/telegram/td_json_client.cpp
new file mode 100644
index 000000000..aa028b05a
--- /dev/null
+++ b/td/telegram/td_json_client.cpp
@@ -0,0 +1,45 @@
+//
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2017
+//
+// 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"
+
+#include "td/telegram/ClientJson.h"
+
+#include "td/utils/Slice.h"
+
+extern "C" int td_json_client_square(int x, const char *str) {
+ return x * x;
+}
+
+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) {
+ static_cast<td::ClientJson *>(client)->send(td::Slice(request));
+}
+
+const char *td_json_client_receive(void *client, double timeout) {
+ auto slice = static_cast<td::ClientJson *>(client)->receive(timeout);
+ if (slice.empty()) {
+ return nullptr;
+ } else {
+ return slice.c_str();
+ }
+}
+
+const char *td_json_client_execute(void *client, const char *request) {
+ auto slice = static_cast<td::ClientJson *>(client)->execute(td::Slice(request));
+ if (slice.empty()) {
+ return nullptr;
+ } else {
+ return slice.c_str();
+ }
+}