Copyright (C) 2015 Google LLC
NearbyConnectionsNative: The sample demonstrates real time multiplayer game on C++ Nearby Connection interface SDK.
- Create nearby_connection interface gpg::NearbyConnections::Builder
- Connect to other peers via StartAdvertising(), StartDiscovery()
- Send messages with SendReliableMessage() and SendUnreliableMessage()
- Clean up Google Nearby Connection with Stop()
- Other in-game communication like relaying connections/messages
For generic play game related instruction, please follow steps described in Getting Started for C++
The build is gradle based. To build from the command line run:
gradlew assembleDebug
In Android Studio, sometimes the first sync of the project cannot find the Android.mk for gpg-sdk. To fix this open the terminal window in Android Studio and run
gradlew gpg-sdk:download_and_stage_gpg_sdk
- Build App
- Install on phone
- Set ONE and ONLY ONE phone/device to be advertising
- All other devices to be discovering after advertising is ready (indicator is "stop" button is enabled)
- Monitor bottom of the UI for "Connected Clients"; once anyone connected, it should be bigger than 0, "Play Game" should be enabled; from here, you could play it at any time
- While playing, your own score and other player's scores should be visible to you at the bottom of the screen note: play time is 30 second by default, and was hard coded as GAME_DURATION in header file
First of all, take a look at our troubleshooting guide. Most setup issues can be solved by following this guide.
If your question is not answered by the troubleshooting guide, we encourage you to post your question to stackoverflow.com. Our team answers questions there reguarly.