From 1b16d54c480165fadd0e6ca4b461aa7b75b7da10 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 16 Jul 2019 22:14:37 +0300 Subject: [PATCH] Remove JavaScript example in favor of third-party wrappers linked in example/README.md. GitOrigin-RevId: b0851a8684a0d2b1ea4a8d863d2120e14b2aecd5 --- example/README.md | 3 +- example/javascript/README.md | 13 ------- example/javascript/example.js | 60 --------------------------------- example/javascript/package.json | 17 ---------- 4 files changed, 1 insertion(+), 92 deletions(-) delete mode 100644 example/javascript/README.md delete mode 100644 example/javascript/example.js delete mode 100644 example/javascript/package.json diff --git a/example/README.md b/example/README.md index af92f4b66..d5ab108ce 100644 --- a/example/README.md +++ b/example/README.md @@ -59,8 +59,7 @@ For example, take a look at [tdl](https://github.com/Bannerets/tdl), which provi at [Airgram](https://github.com/airgram/airgram) - modern TDLib framework for TypeScript/JavaScript. You can also see [node-tdlib](https://github.com/wfjsw/node-tdlib), [tdlnode](https://github.com/fonbah/tdlnode), [tglib](https://github.com/nodegin/tglib), -[Paper Plane](https://github.com/BlackSuited/paper-plane), [node-tlg](https://github.com/dilongfa/node-tlg) and -[example/javascript](https://github.com/tdlib/td/tree/master/example/javascript) for other examples of TDLib JSON interface integration with Node.js. +[Paper Plane](https://github.com/BlackSuited/paper-plane) and [node-tlg](https://github.com/dilongfa/node-tlg) for other examples of TDLib JSON interface integration with Node.js. TDLib can be used also from NativeScript through the [JSON](https://github.com/tdlib/td#using-json) interface. See [nativescript-tglib](https://github.com/arpit2438735/nativescript-tglib) as an example of a NativeScript library for building Telegram clients. diff --git a/example/javascript/README.md b/example/javascript/README.md deleted file mode 100644 index c94fb5414..000000000 --- a/example/javascript/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# TDLib JavaScript (Node.js) example - -#### Requirements - -- Node.js v9.0.0+ -- [Prebuilt](https://github.com/tdlib/td#building) tdjson shared library - -#### Run - -```console -$ npm install -$ node example.js -``` diff --git a/example/javascript/example.js b/example/javascript/example.js deleted file mode 100644 index 4c0e078a9..000000000 --- a/example/javascript/example.js +++ /dev/null @@ -1,60 +0,0 @@ -const ffi = require('ffi-napi') -const ref = require('ref-napi') - -function buildQuery (query) { - const buffer = Buffer.from(JSON.stringify(query) + '\0', 'utf-8') - buffer.type = ref.types.CString - return buffer -} - -const PATH_TO_LIBRARY_FILE = 'libtdjson' - -const tdlib = ffi.Library( - PATH_TO_LIBRARY_FILE, - { - 'td_json_client_create' : ['pointer', []], - 'td_json_client_send' : ['void' , ['pointer', 'string']], - 'td_json_client_receive' : ['string' , ['pointer', 'double']], - 'td_json_client_execute' : ['string' , ['pointer', 'string']], - 'td_json_client_destroy' : ['void' , ['pointer']], - } -) - -// Create client -const client = tdlib.td_json_client_create() - -function send (query) { - tdlib.td_json_client_send(client, buildQuery(query)) -} - -function execute (query) { - return JSON.parse( - tdlib.td_json_client_execute(client, buildQuery(query)) - ) -} - -function receive () { - const timeout = 2 - return JSON.parse( - tdlib.td_json_client_receive(client, timeout) - ) -} - -function destroy () { - tdlib.td_json_client_destroy(client) -} - -// Testing execute -console.log('execute', execute({ - '@type': 'getTextEntities', - 'text': '@telegram /test_command https://telegram.org telegram.me' -})) - -// Testing send -send({ '@type': 'getAuthorizationState' }) - -// Testing receive -console.log('receive', receive()) - -// Destroy client -destroy() diff --git a/example/javascript/package.json b/example/javascript/package.json deleted file mode 100644 index a2bd6eef6..000000000 --- a/example/javascript/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "tdlib-js-example", - "version": "1.0.0", - "description": "", - "private": true, - "main": "example.js", - "scripts": { - "start": "node example.js" - }, - "engines": { - "node": ">= 9.0.0" - }, - "dependencies": { - "ffi-napi": "^2.4.3", - "ref-napi": "^1.4.0" - } -}