Skip to content

Instantly share code, notes, and snippets.

@FruitieX
Last active November 9, 2017 12:30
Show Gist options
  • Select an option

  • Save FruitieX/743b7db9166fef4f05b31bfe298bca49 to your computer and use it in GitHub Desktop.

Select an option

Save FruitieX/743b7db9166fef4f05b31bfe298bca49 to your computer and use it in GitHub Desktop.
Klockbadis api

Room setup

Player 1

  1. Open a websocket connection to server, gets auto-assigned to new room with random PIN.

    Reply:

    {
      "event": "room",
      "data": {
        "id": "1584",
        "player1": {
          "score": 0
        }
      }
    }
    
  2. Give PIN to player 2, wait until player 2 connects. Once that happens the following message is received:

    {
      "event": "room",
      "data": {
        "id": "1584",
        "player1": {
          "score": 0
        },
        "player2": {
          "score": 0
        }
      }
    }
    

Player 2

  1. Open a websocket connection to server, gets auto-assigned to new room with random PIN.

    Reply:

    {
      "event": "room",
      "data": {
        "id": "7582",
        "player1": {
          "score":0
        }
      }
    }
    
  2. Get PIN from player 1, send the following message to join player 1's room:

    {
      "event": "join",
      "data": {
        "id": "1584"
      }
    }
    

Sending updates to score

Player 1 & Player 2

Send the following event:

{
  "event": "point",
  "data": {
    "id":"1584",
    "playerKey":"player2",
    "score":3
  }
}
  • id is the room ID (PIN code)
  • playerKey is the player whose score to update
  • score is the new score
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment