Skip to content

Feature/multipeer #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 31, 2020
Merged

Feature/multipeer #1

merged 6 commits into from
Jan 31, 2020

Conversation

code-matt
Copy link
Owner

adding multipeer with worldmap sharing

@code-matt
Copy link
Owner Author

WIP

        <ARKit
          ....
          onMultipeerJsonDataReceived={event => {
            Vibration.vibrate(300);
            let {data} = event.nativeEvent;
            console.log(data);
          }}
          onPeerConnected={(event) => {
            Vibration.vibrate(1000);
            console.log('peer connected!!!');
            console.log(event.nativeEvent.peer);
          }}
          onPeerDisconnected={(event) => {
            Vibration.vibrate(1000);
            console.log('peer disconnected!!!');
            console.log(event.nativeEvent.peer);
          }}
          onPeerConnecting={(event) => {
            Vibration.vibrate(1000);
            console.log('peer connecting!!!');
            console.log(event.nativeEvent.peer);
          }}
        </ARKit>
ARKit.sendWorldmapData(); // sends worldmap data to all peers

ARKit.startBrowsingForPeers('somename'); // hosting a multipeer session called some name

ARKit.advertiseReadyToJoinSession('somename'); // start looking for and automatically join a session called 'somename'

ARKit.sendDataToAllPeers({test: 'data'})
  .then(res => {
    console.log('data send success: ', res); // res is [null] for a success for now
  })
  .catch(error => {
    console.log('error');
  });

// track uuids with your own state and the multipeer connection state callbacks
ARKit.sendDataToPeers([<peerUUIDstring>, <peerUUIDstring>], {test: 'data'})
  .then(res => {
    console.log('data send success: ', res); // res is [null] for a success for now
  })
  .catch(error => {
    console.log('error');
  });

// ARKit.openMultipeerBrowser() // open the iOS multipeer browser and see who is connected and also disconnect them.. people need names eventually

@code-matt code-matt merged commit 2ae58ca into master Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant