dslink
TypeScript icon, indicating that this package has built-in type declarations

2.2.22 • Public • Published

sdk-dslink-ts

JavaScript / Typescript SDK for the DSA protocol.

Version 2.0 of this sdk is re-written with typescript and is NOT backward compatible with the DSA javascript sdk 1.x.

Install

npm install dslink --save
or
yarn add dslink

Use Typescript

To compile with dslink sdk's typescript definition, make sure esModuleInterop flag is true in typescript compilerOptions.

Install DsLink on broker

You can zip a javascript dslink and install it on dglux-server.

A working example

Nodejs Example (responder)

A sample dslink with a basic value node at the path /value

const {DSLink, RootNode, ValueNode} = require("dslink");

class MyValueNode extends ValueNode {
  constructor(path, provider) {
    super(path, provider, 'myvalue', 'number');
    this._value = 123;
  }
}

function main() {
  let rootNode = new RootNode();
  rootNode.createChild('value', MyValueNode);

  let link = new DSLink('mydslink', {rootNode});
  link.connect();
}

main();

Browser Example (requester only)

const {DSLink} = require('dslink/js/web');

async function main() {
    let link = new DSLink('ws://localhost:8080/ws', 'json');
    link.connect();

    let {requester} = link;

    console.log(await requester.subscribeOnce('/sys/dataOutPerSecond'));
}

main();

Readme

Keywords

none

Package Sidebar

Install

npm i dslink

Weekly Downloads

11

Version

2.2.22

License

Apache-2.0

Unpacked Size

944 kB

Total Files

335

Last publish

Collaborators

  • mbullington
  • rinick