Skip to content

3. Updating, Reconnecting & Disconnecting

Florian König edited this page Dec 1, 2022 · 2 revisions

Items marked with ⚠ include breaking changes from v1 to v2.

Getting the Current Board State

It's easy to verify your current board state with the server. Send this message:

{
  "type": "get-board"
}

and the backend will reply with the board's current FEN:

{
  "type": "board",
  "fen": "$fen"
}

⚠ Reconnecting

Due to the nature of the backend's deployment on Google Cloud Run, the WebSocket connection will be terminated after a while (currently 5 minutes). You can easily return to the game you participated in before.

Connect to wss://api.pawn-hub.de/reconnect?id=${id}&reconnectCode=${reconnectCode} with your previous id and reconnect code.

You will get a confirmation message with a new reconnect code. You will have to use the new code the next time you want to reconnect:

{
  "type": "reconnected",
  "reconnectCode": "$new-reconnect-code"
}

Disconnecting

To disconnect, send this message. The backend will end the game and prevent reconnecting.

{
  "type": "disconnect"
}

Your opponent will be notified of your disonnect:

{
  "type": "opponent-disconnected"
}
  • If you were a host, the attendee's connection will be closed and the current game removed.
  • If you were an attendee, you will be removed from the current game, your connection closed, and the game will be reset.

Clone this wiki locally