Remove JavaScript example in favor of third-party wrappers linked in example/README.md.

GitOrigin-RevId: b0851a8684a0d2b1ea4a8d863d2120e14b2aecd5
This commit is contained in:
levlam 2019-07-16 22:14:37 +03:00
parent c26b05ab69
commit 1b16d54c48
4 changed files with 1 additions and 92 deletions

View File

@ -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.

View File

@ -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
```

View File

@ -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()

View File

@ -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"
}
}