send() / get()

The send and get functions are used together to share data between multiple devices running your app.

The send command pushes whatever you want out to every other device currently looking at your app. Those other devices receive the message via the get function.

For example, this program allows multiple people to send alerts to everyone else's device.

To see this code work, make an app with the lines above, then scan the app's QR code onto a phone. Tap the screen on the computer, and the phone will say something like "They tapped position 376,124". Tap the phone, and the computer will do the same.

The exchange happens fast, so the send and get methods allow you to make mutliplayer, real-time games. Here's a more interesting example. It gives every player an avatar they can move with their finger.