<commit_before># react-native-multipeer

Communicate over ad hoc wifi using Multipeer Connectivity.

## Known Issues
Below is a list of known issues. Pull requests are welcome for any of these issues!

- No support for streams in React Native, so streaming is currently unavailable.
- No support for resource transfers: I want this to work seamlessly with other file resources for other uses, so I'm waiting for those specs to be finalized.

## Getting started

1. `npm install react-native-multipeer@latest --save`
2. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
3. Go to `node_modules` ➜ `react-native-multipeer` and add `RCTMultipeerConnectivity.xcodeproj`
4. In XCode, in the project navigator, select your project. Add `libRCTMultipeerConnectivity.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
5. Click `RCTMultipeerConnectivity.xcodeproj` in the project navigator and go the `Build Settings` tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for `Header Search Paths` and make sure it contains both `$(SRCROOT)/../react-native/React` and `$(SRCROOT)/../../React` - mark both as `recursive`.
5. Run your project (`Cmd+R`)

## Usage

All you need is to `require` the `react-native-multipeer` module and then you can start using the singleton instance.

```javascript
var React = require('react-native');
var {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableHighlight
} = React;
var MultipeerConnectivity = require('react-native-multipeer');

function getStateFromSources() {
  var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
    return {
      dataSource: ds.cloneWithRows(_.values(MultipeerConnectivity.getAllPeers()))
    };
}

var peerApp = React.createClass({
  getInitialState: function() {
    return getStateFromSources()
  },
  componentDidMount() {
    MultipeerConnectivity.on('peerFound', this._onChange);
    MultipeerConnectivity.on('peerLost', this._onChange);
    MultipeerConnectivity.on('invite', ((event) => {
      // Automatically accept invitations
      MultipeerConnectivity.rsvp(event.invite.id, true);
    }).bind(this));<commit_msg>Updating README with working example<commit_after># react-native-multipeer

Communicate over ad hoc wifi using Multipeer Connectivity.

## Known Issues
Below is a list of known issues. Pull requests are welcome for any of these issues!

- No support for streams in React Native, so streaming is currently unavailable.
- No support for resource transfers: I want this to work seamlessly with other file resources for other uses, so I'm waiting for those specs to be finalized.

## Getting started

1. `npm install react-native-multipeer@latest --save`
2. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
3. Go to `node_modules` ➜ `react-native-multipeer` and add `RCTMultipeerConnectivity.xcodeproj`
4. In XCode, in the project navigator, select your project. Add `libRCTMultipeerConnectivity.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
5. Click `RCTMultipeerConnectivity.xcodeproj` in the project navigator and go the `Build Settings` tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for `Header Search Paths` and make sure it contains both `$(SRCROOT)/../react-native/React` and `$(SRCROOT)/../../React` - mark both as `recursive`.
5. Run your project (`Cmd+R`)

## Usage

All you need is to `require` the `react-native-multipeer` module and then you can start using the singleton instance.

```javascript
var React = require('react-native');
var {
  AppRegistry,
  ListView,
  StyleSheet,
  Text,
  View,
  TouchableHighlight
} = React;
var MultipeerConnectivity = require('react-native-multipeer');

function getStateFromSources() {
  var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
    return {
      dataSource: ds.cloneWithRows(MultipeerConnectivity.getAllPeers())
    };
}

var peerApp = React.createClass({
  getInitialState: function() {
    return getStateFromSources()
  },
  componentDidMount() {
    MultipeerConnectivity.on('peerFound', this._onChange);
    MultipeerConnectivity.on('peerLost', this._onChange);
    MultipeerConnectivity.on('invite', ((event) => {
      // Automatically accept invitations
      MultipeerConnectivity.rsvp(event.invite.id, true);
    }).bind(this));
{'fraction_non_alphanumeric': 0.10835419986341907, 'fraction_numerical': 0.004552697473252903, 'mean_word_length': 4.527044025157233, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4274510', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1319, 'n_words': 470}