1.0.8 • Published 2 months ago

multicast-device-discovery v1.0.8

Weekly downloads
-
License
ISC
Repository
-
Last release
2 months ago

device-dicovery

The provided code utilizes the Bonjour protocol to discover nearby devices on the same network as the server is connected to. The application continuously listens for Bonjour events related to a custom service type. The discovered devices are tracked and stored in an array, including their relevant information such as address, fully qualified domain name (fqdn), and the timestamp of the last update.

The structure is designed to be modular and generic, allowing for easy customization and potential use as a library. The code includes error handling, and there's a cleanup function to clear intervals and remove event listeners when needed.

INSTALLATION

npm install multicast-device-discovery

USAGE

const DeviceDiscovery = require("multicast-device-discovery");

const options = {
  deviceTimeoutThreshold: 3000,
  serviceType: "adb-tls-connect",
};
const deviceDiscovery = new DeviceDiscovery(options);

deviceDiscovery.on("Update", (devices) => {
  console.log("Devices have changed:", devices);
});

deviceDiscovery.on("Device Discovery Error", (error) => {
  console.error(`An error occurred: ${error}`);
});

deviceDiscovery.startDeviceDiscovery();

//deviceDiscovery.cleanup() //this function can be used for cleanup

Events to subscribe

  1. Update
  2. Error

Options

  1. deviceTimeoutThreshold (Milliseconds)
  2. serviceType (refer)

This is an open-source Project, Please feel free to contribute ❤️

1.0.8

2 months ago

1.0.7

3 months ago

1.0.6

3 months ago

1.0.5

3 months ago

1.0.4

3 months ago

1.0.3

3 months ago

1.0.2

3 months ago

1.0.1

3 months ago

1.0.0

3 months ago