Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
0.17.0
-
None
-
HarmonyOS devices
Description
Currently thrift can be run on Node.js. Hope it can also support creating TCP connection on OpenHarmonyOS.
For example, we can get data from a web server as follows:
const connection = thrift.createOhosConnection(http.createHttp, host, 80, { protocol: TJSONProtocol, header: { 'Content-Type': 'application/json' }, createHttp: http.createHttp }), client = thrift.createOhosClient(TAccountService, connection); const account = { uid: 1, name: 'hello' } console.info('requesting...') client.createAccount(account).then(() => { console.info('client createAccount:', account.uid); client.getAccount(account.uid).then((resp) => { console.info(`client getAccount: uid=${resp.uid}, name=${resp.name}`); this.user = resp }).catch(e => { console.info(e) }) }).catch(e => { console.info(e) })
Maybe we can add 'ohos_connection.js' module under Node.js lib to achieve it.
Here is the demo. You can run it on [DevEco Studio|https://developer.harmonyos.com/en/develop/deveco-studio/], and the result after pressing button will be like the screenshot in README.
For more information about OpenHarmonyOS see this site.
Attachments
Issue Links
- links to