$ npm install
$ node index.js
When the user enters their name/photo, the device registers. The next time the app is open, it makes a request to register with the existing name/photo stored on the device.
Creating a new device:
- name=Your Name
- avatar=base64-encoded image
Updating an existing device:
- access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- name=Your Name
- avatar=base64-encoded image
Response:
- device_id
- access_token
Whatever device_id and access_token are returned by the register route should replace the values currently stored on the phone if any.
Update the push notification tokens for the device.
- access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
And one of:
- gcm_registration_id=XXXXX
- apns_prod_token=XXXXX
- apns_sandbox_token=XXXXX
Generates a new board_id
- access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Response:
- board_id: XXXXXXXX
Note that this doesn't actually make any API requests or do anything other than generate an ID for you.
- access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- latitude=XXX
- longitude=XXX
Response:
- board_id
- name
- distance - meters
- bbox - [x,y,x,y]
- game:
- game_id
- is_active - true, false
- red_team - number of people on the red team
- blue_team
- red_score - total score for the red team
- blue_score - total score for the blue team
- access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- board_id
Response:
- board
- board_id
- name - The title or "Untitled Board"
- bbox - [x,y,x,y]
- coins - Array
- coin_id
- latitude
- longitude
- value
Create a game given an existing board
- access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- board_id=XXXXXXXXXXXXXXXXXXXX
Response:
- game_id
Start an existing game
Internally, this applies the "active" game tag to the board's triggers, activating them for each device.
- access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- game_id=XXXXXXXXXXXXXXXXXXXX
The device is joining an existing game
- access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- game_id=XXXXXXXXXXXXXXXXXXXX
Response:
- team=red or blue
Retrieve all player and coin locations and state for a game
- access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- game_id=XXXXXXXXXXXXXXXXXXXX
Response:
- game - Object
- game_id
- active - true, false
- name
- bbox - [x,y,x,y]
- creator
- device_id
- name
- team
- teams - Object
- blue
- size
- score
- red
- size
- score
- coins - Array
- coin_id
- latitude
- longitude
- value
- team - null, red, blue
- players - Array
- device_id
- team
- score
- latitude
- longitude
- timestamp
- speed
- name
The creator of the game ends the game. This de-activates all the triggers, and removes the game tag from all players' devices.
- access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- game_id=XXXXXXXXXXXXXXXXXXXX
Return a user's avatar as a JPG image.
Documenting all the UDP messages that are sent and received. UDP messages are JSON encoded going up and down.
- type - "player"
- device_id - String
- latitude - Float
- longitude - Float
- timestamp - Unix timestamp
- speed - Int, km/h
- bearing - Int
- accuracy - Int, meters
- name
- team
- score
- type - "coin"
- coin_id - String
- latitude - Float
- longitude - Float
- timestamp - Unix timestamp
- team - red, blue
- value - Int
- device_id - String - who captured the coin
- player_score - Int - total score for the player who captured this coin
- red_score - Int
- blue_score - Int
- type - "game"
- board_id - String
- red_players - Int
- blue_players - Int
- red_score - Int
- blue_score - Int
- type - "game_start"
- game_id - String
- type - "game_end"
- game_id - String
- type - "player_join"
- device_id - String
- name - String
- team - red, blue
- access_token - String
- latitude - Float
- longitude - Float
- timestamp - Unix timestamp
- speed - Int, km/h
- bearing - Int
- accuracy - Int, meters
Documenting the usage of the Geotrigger API.
The board is represented as a large polygon trigger.
Tags:
- board - indicates that this trigger is a board, used to search for "board" triggers
- board:XXXXXX - specifies the board_id of this trigger
- board:twitter_id:XXXXXX - the Twitter ID of the person who created the board, for access control
Properties:
- title
Each coin is a point+distance trigger.
Tags:
- coin - indicates that this trigger is a coin
- coin:board:XXXXXX - the board_id this coin belongs to
- game:XXXXXX - the game_id this coin belongs to (activates this trigger for the game)
Properties:
- value: 10 (10, 20, 50)
- team: red (red, blue, [none])
A player is active in a game when their device has a tag like the following
- game:XXXXXX
Documenting all the keys used in Redis.
Profile data:
- Key: device:profile:XXXXXX => JSON object
AGO access tokens:
- Key: device:tokens:XXXXXX => JSON object
Active game for the device:
- Key: device:active_game:XXXXXX => {game_id: "XXXX", team: "red"}
Last location of each device
- Value: device:location:XXXXXX => JSON object
Set of members of each team of a game:
- Set: game:XXXXXX:red:members => device_ids
- Set: game:XXXXXX:blue:members => device_ids
Scores of each device
- Hash: game:XXXXXX:red device:XXXXXX => Number
- Hash: game:XXXXXX:blue device:XXXXXX => Number
- HINCRBY game:XXXXXX:red device:XXXXXX 1
Game title and bounding box, copied to Redis when a game is created from a board
- Value: game:XXXXXX:data => {name, bbox, creator}
- creator => {device_id, name}
Coin data, copied to Redis when a game is created from a board
- Hash game:XXXXXX:coin_data XXXXXX => {coin_id, latitude, longitude, value}
Which team has claimed a coin
- Hash game:XXXXXX:coins XXXXXX => red/blue
Total score for red team:
- HVALS game:XXXXXX:red => list of numbers
Active game for the board
- Value: board:XXXXXX:game => game_id
Get the board for a game
- Value: game:XXXXXX:board => board_id
curly http://api.mapattack.org/device/register
returns an access token
curly http://api.mapattack.org/board/list -d latitude=45.5165 -d longitude=-122.6764 -d access_token=XX
returns a list of boards
curly http://api.mapattack.org/game/create -d access_token=XX -d board_id=x
returns a game_id
curly http://api.mapattack.org/game/start -d access_token=XX -d game_id=x