Skip to content

IOT-DSA/sdk-dslink-ts

This branch is 1 commit ahead of master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

cb493ed · Jul 11, 2023
Apr 11, 2022
Nov 24, 2019
Oct 25, 2022
Mar 10, 2021
Oct 25, 2022
Oct 25, 2022
Jan 16, 2019
Apr 17, 2021
Mar 31, 2020
Jul 31, 2021
Jul 9, 2019
Nov 15, 2019
Jul 12, 2019
Jul 20, 2019
Jul 25, 2019
Oct 25, 2022
Apr 20, 2021
Feb 1, 2019
Nov 22, 2019
Jul 11, 2023

Repository files navigation

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

About

typescript/javascript sdk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published