It can be helpful when you try to get a list of your local devices over WiFi when the devices includes at least one websocket connection.
This package allows you detect all devices over your local network with websocket connection.
You've to add a timeout and an array of ports as parameters. The package will try to create a connection with those ports and return the ip adresses which have successful connection.
See the example: https://github.com/RichardRNStudio/react-native-find-local-devices/tree/main/example
NOTICE: It doesn't work with IOS yet. If you can help me in this case please contact me on the following email: info@rnstudio.hu
This package has been written for the PC Controller react-native application as a submodule.
npm install react-native-find-local-devices --save
NOTICE: It requires a real device with Wi-Fi connection
npm run example:android
import PortScanner from 'react-native-find-local-devices';
const scanner = new PortScanner({
ports: [8000],
onDeviceFound: (device) => {
consoe.log('Found device!', device);
},
onResults: (devices) => {
console.log('Finished scanning', devices);
},
onCheck: (device) => {
console.log('Checking IP: ', device.ipAddress);
},
onFinished: () => {
console.log("Done!");
},
onError: (device) => {
// Called when no service found
console.log("Nothing found", device);
}
})
// When the discovering is running, you can cancel that with the following function:
scanner.stop();
// ...
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT