This readme provides information about the backend part of the jetlag.gg game.
- Windows - https://docs.docker.com/desktop/windows/install/
- Linux - https://docs.docker.com/desktop/linux/install/
./start.sh
It kills all existing containers, rebuilds images and starts new containers
copy redis folder (with dockerfile) to the server, and then:
- create volume
docker volume create redis_data
- create the network
docker network create game_net
- build the image
docker build -t redis_with_persistency redis/
- remove any existing redis containers and run a new one
docker rm -f redis;docker run --rm -d -p 6379:6379 -v redis_data:/data --network game_net --name redis redis_with_persistency
- 9999 - websockets & http
GET /api/game/config/
GET /api/game/leaderboard/
with pagination
GET /api/game/leaderboard/?limit=10&offset=30
where limit is the size of one page
useful for determining player's position after the game
GET /api/game/leaderboard/john:1/
returns last 10 games of a player
GET /api/game/leaderboard/john:1/last_games/
POST /api/game/players/
required before creating ws connection
"token" header is expected to be present in the request
POST /api/game/join/
"token" header is expected to be present in the request
POST /api/game/exit/
only 1 connection per user at a time is allowed
GET /ws/
(set player token in the protocol)
new WebSocket("ws://127.0.0.1:9999/ws/", "player_token")
{
created: integer timestamp (in milliseconds),
data: json,
type: str event type
}
- 'player.list'
- 'player.connected'
- 'player.registered'
- 'player.disconnected'
- 'player.removed'
- 'player.updated'
- 'player_position.updated'
- 'airport.shipment_delivered'
- 'airport.refueling_stopped'
- 'airport.list'
- 'airport.updated'
- 'player_position.update_request'
sample:
ws.send(JSON.stringify({type: 'player_position.update_request', created: new Date().getTime(), data: {bearing: 30, velocity: 2000, timestamp: new Date().getTime()}}))
- 'airport.landing_request'
sample:
ws.send(JSON.stringify({type: 'airport.landing_request', created: new Date().getTime(), data: {id: "d5e69764-ac04-42d4-a2cc-2f6fd8554f47"}}))
where id is the id of the airport.
- 'airport.departure_request'
sample:
ws.send(JSON.stringify({type: 'airport.departure_request', created: new Date().getTime(), data: {id: "d5e69764-ac04-42d4-a2cc-2f6fd8554f47"}}))
where id is the id of the airport.
- 'airport.shipment_dispatch_request'
sample:
ws.send(JSON.stringify({type: 'airport.shipment_dispatch_request', created: new Date().getTime(), data: {id: "d5e69764-ac04-42d4-a2cc-2f6fd8554f47"}}))
where id is the id of the shipment. Player has to be grounded and shipment must be present on the airport player is grounded on.
- 'airport.shipment_delivery_request'
sample:
ws.send(JSON.stringify({type: 'airport.shipment_delivery_request', created: new Date().getTime(), data: {}}))
player has to carry a shipment and be grounded on the destination airport of the shipment.
- 'airport.refueling_start_request'
sample:
ws.send(JSON.stringify({type: 'airport.refueling_start_request', created: new Date().getTime(), data: {}}))
- 'airport.refueling_end_request'
sample:
ws.send(JSON.stringify({type: 'airport.refueling_end_request', created: new Date().getTime(), data: {}}))
GET /clock/ (websocket)
sample:
ws.send("test123")
{t: 1653085964101, ref: "test123"}
Created by @decomorreno - feel free to contact me!
The project is provided as is and can be used within the bounds of GPLv3 licence.
However please do contact us before you fork or copy the project as we would rather have the improvements of any kind implemented within this project, and you are free to submit pull requests with fixes and new features.