googlesamples / ios-nearby

68 stars 30 forks source link

Transfer data #15

Open Venko132 opened 8 years ago

Venko132 commented 8 years ago

Hello, I have got few questions in using of nearby-api. From documentation: "The server facilitates message exchange between two devices when both are associated with a common token" 1) Will two ios devices use to transfer data peer-to-peer(or other local) connection? Or they will use Google Cloud server? 2) When communicate ios and android devices, will they use to transfer data Google Cloud server, or they transfer it in local network?

3) Can I communicate with special one (not with all devices) - send data only for him? And vice versa - only receive data from it. If yes, can you give example?

dan-webb commented 8 years ago

Hello,

Happy to answer your questions! 1&2) Two iOS/Android devices will use BLE (Bluetooth Low Energy) and/or high frequency audio to exchange a token, which is pure peer-to-peer. The receipt of a token by either device establishes the connection. The token is then sent to the Google Nearby server, at which point data can be exchanged between the two devices via the cloud. 3) Nearby Messages is not connection-based; it uses a broadcast model, so all devices that are within proximity of the publishing device will be able to receive the published data. You can build a connection-based protocol on top of it by performing a security handshake between two of them, but it would suffer from very high latency, due to the way Nearby Messages are exchanged.