Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5535

Ability to support connection on OpenHarmonyOS

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.17.0
    • 0.17.0
    • Node.js - Library
    • 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

          Activity

            People

              maomao381 konpekicode
              maomao381 konpekicode
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m