Search code examples
javascriptnode.jsupnptabristabris-js

TabrisJs working with Upnp


Upnp looks harder to work with in TabrisJs.
It supports node packages to a large extent, but I am finding a tough time working with Upnp.

In package.json I got node-upnp-client

"dependencies": {
    "tabris": "^2.0.0-rc2",
    "moment": "~2.8.4",
    "moment-timezone": "~0.2.5",
    "android-versions": "1.1.0", 
    "node-mind": "1.0.1",
    "node-ssdp": "3.2.1",
    "node-upnp-client" : "0.0.2",
    "node-ssdp-lite": "0.2.0"
  },

In app js I have initialized it as

const upnpClient = require('node-upnp-client');
const cli = new upnpClient();
console.log(cli.searchDevices());

I am getting

Could not load main module: 
Reference error: process is not defined

Now its pointing to this line first var path = process.env.SSDP_COV ? './lib-cov/' : './lib/', in node-ssdp/index.js, ^

I dont know why but it works perfectly in the CLI but not in the app.

Requiring node-ssdp alone says it can't load dgram, even though it is part of Node

And I am not sure if the dgram package is available separately.

How to rectify these error and get Upnp support in tabrisJs?


Solution

  • Tabris.js uses a Node.js compatible module system to allow using modules hosted on npm in your app. However, it does not implement most of the Node.js APIs.

    Some basic APIs like Timer and Console are available. In addition to that, a small subset of the Node APIs is supported by the tabris-js-node module. Unfortunately, the network APIs of Node.js (dgram is one of them) are not implemented in Tabris.js.

    This rules out npm plugins that build on these APIs. You'd have to implement this functionality on top of Tabris APIs such as fetch or websockets.