1.1.0 • Published 10 months ago

lms-discovery v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

lms-discovery

Logitech Media Server discovery for Node.js

Install

npm install --save lms-discovery

Usage

// ESM
import discovery from 'lms-discovery';
// CJS
const discovery = require('lms-discovery');

discovery.on('discovered', (server) => {
    console.log('Server discovered:', server);
});

discovery.on('lost', (server) => {
    // Do something with lost server
});

discovery.start();

...

discovery.stop();


// Output
Server discovered: {
    ip: '192.168.1.85',     // Server's IP address
    name: 'my-lms-server',  // Server name
    ver: '8.2.1',           // Server version
    uuid: '187fa185-d108-408b-a8bd-8f5a4bb855bd',  // Unique identifier
    jsonPort: '9000',       // Port for JSON-RPC requests
    cliPort: '9090'         // Port for CLI commands and queries   
}

Run example:

npm run example

API

Params

  • options: (optional and all properties optional)
    • broadcastAddress: (string) network address used to transmit discovery requests. Default: 255.255.255.255.
    • discoveredTTL: (number) how long in milliseconds to wait for a discovered server to respond to a subsqeuent discovery request before it is presumed lost. Only applicable for servers that do not advertise cliPort. Default: 60000 (60 seconds).
    • discoverInterval: (number) how often in milliseconds to broadcast discovery requests. Default: 30000 (30 seconds).

discoveredTTL must be larger than discoverInterval.



Returns

running or stop


Returns

Array<ServerInfo>


Params

  • enabled: (boolean)
  • callback: (function)
    • If specified, debug messages will be passed to callback.
    • If not specified, debug messages will be printed to console.

Events

Listener Params


Emitted when a server is lost.

Listener Params


Listener Params

  • error: (any)

Changelog

1.1.0:

  • Instead of detecting server lost through discoveredTTL timers, emit 'lost' events immediately as they occur for servers that advertise cliPort.

1.0.0:

  • Migrate to TypeScript and package as ESM / CJS hybrid module

0.1.0:

  • Initial release

License

MIT