rn-local-p2p
v0.2.7
Published
Peer to peer connection library over a local network, WiFi, without internet access using UDP
Readme
rn-local-p2p
Peer to peer connection library over a local network, WiFi, without internet access using UDP
Warning: This library is in pre-release state and should be used with caution. It has not been tested at scale in production environments, and both the API and internal implementations are subject to frequent changes. Use at your own risk.
TODO:
- Improve test coverage
- Add created and updated at timestamps to pairings
Installation
npm install rn-local-p2pUsage
// ...Creating Router
import { createRouter } from './Router';
import { RequestResponse } from './RequestResponse';
// Define your types
interface Message {
id: string;
content: string;
}
const router = createRouter()
.get('/messages', async () => ({
status: 200,
body: [] as Message[],
}))
.post('/messages', async (req: HttpRequest<{ content: string }>) => ({
status: 201,
body: { id: '123', content: req.body.content } as Message,
}));
router.initialize(yourRequestResponseInstance);Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library
Installation
Install the library:
npm install your-library-nameReact Native Specific Setup (Required):
Because this library uses Node.js core modules (specifically,
cryptoand its dependencies), you must usern-nodeifyto make it compatible with React Native. This step is essential for your application to build and run correctly.a. Install
rn-nodeifyas a dev dependency in your application:npm install --save-dev rn-nodeifyb. Run
rn-nodeifyto install the necessary shims and configure yourpackage.json:npx rn-nodeify --install "stream,buffer,events,crypto,vm,process" --hackc. Ensure that your
package.jsonhas been modified correctly. It should have: _stream-browserify,buffer,events,vm-browserifyandprocesslisted underdependencies. _rn-nodeifylisted underdevDependencies. _ Abrowserfield mappingstream,buffer,events,crypto,vm, andprocessto their respective browserify shims. _ Apostinstallscript in thescriptssection that runsrn-nodeify.d. Important: After running
rn-nodeify, you must clean your build and restart the Metro bundler:- Stop the Metro bundler (Ctrl+C or Cmd+C).
- Clear Watchman watches:
watchman watch-del-all - Delete the
node_modulesdirectory:rm -rf node_modules - Clear Metro Cache:
npx react-native start --reset-cache - Reinstall dependencies:
npm install - (iOS Only) Clean and rebuild your iOS project:
cd ios && rm -rf Pods && rm -rf build && pod install && cd .. - Restart the Metro bundler:
npm start - Rebuild your application:
npx react-native run-androidornpx react-native run-ios
Import
react-native-get-random-values: Add this line at the very top of the root file (index.js):import 'react-native-get-random-values';
