react-native-handshake
This simple module is intended to be used with the react-native-nsd module to send and receive handshake messages to/from other discovered peers.
Getting started
$ npm install react-native-handshake --save
Mostly automatic installation
$ react-native link react-native-handshake
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import net.altermundi.rn_handshake.HandshakePackage;
to the imports at the top of the file - Add
new HandshakePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-handshake' project(':react-native-handshake').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sd/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-handshake')
Usage
;; let HANDSHAKE_MESSAGE = "My cool message" DeviceEventEmitter; DeviceEventEmitter; DeviceEventEmitter; // Start the server. Will emit HANDSHAKE_MESSAGE to any client that connects Handshake; // receive a Handshake message from a server/peer. Will emit a peerPubKeyReceived event with the handshake message received (key).Handshake; // Stop the handshake serverHandshake