Logitech Media Server discovery for Node.js
npm install --save lms-discovery
// 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
start([options])
Starts the discovery service.
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 advertisecliPort
. Default:60000
(60 seconds).discoverInterval
: (number) how often in milliseconds to broadcast discovery requests. Default:30000
(30 seconds).
discoveredTTL
must be larger thandiscoverInterval
.
stop()
Stops the discovery service.
getStatus()
Gets the status of the discovery service.
Returns
running
or stop
setDebug(enabled[, callback])
Whether to enable debug messages.
Params
enabled
: (boolean)callback
: (function)- If specified, debug messages will be passed to
callback
. - If not specified, debug messages will be printed to console.
- If specified, debug messages will be passed to
on('discovered', (server) => ...)
Emitted when a server is discovered.
Listener Params
server
: ServerInfo
on('error', (error) => ...)
Emitted when an error has occurred.
Listener Params
error
: (any)
1.1.0:
- Instead of detecting server lost through
discoveredTTL
timers, emit 'lost' events immediately as they occur for servers that advertisecliPort
.
1.0.0:
- Migrate to TypeScript and package as ESM / CJS hybrid module
0.1.0:
- Initial release
MIT