RichardRNStudio / react-native-find-local-devices

This package loads all of the local devices for react native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🚀 react-native-find-local-devices

npm version build platform license

example

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.

Visit the PC Controller website

Installation

npm install react-native-find-local-devices --save

Running the example project

NOTICE: It requires a real device with Wi-Fi connection

npm run example:android

Usage

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();
// ...

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

About

This package loads all of the local devices for react native

License:MIT License


Languages

Language:Java 42.5%Language:TypeScript 18.6%Language:JavaScript 13.4%Language:Ruby 13.2%Language:Objective-C 11.0%Language:Swift 1.0%Language:C 0.3%