Skip to content

1. Setting up a Connection

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

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

To connect two clients (host and attendee):

⚠ Connect as host

Simply connect to wss://api.pawn-hub.de/host. You'll get a reply containing your id and reconnect code:

{
  "type": "connected",
  "host": true,
  "id": "$hostId",
  "reconnect-code": "$reconnect-code"
}

⚠ Request to Connect the Attendee:

Connect to wss://api.pawn-hub.de/connect?id=${hostId}&code=${code} You will get an id and reconnect code again:

{
  "type": "connected",
  "host": false,
  "id": "$attendeeId",
  "reconnect-code": "$reconnect-code"
}

Accept or Decline a Connection Request

Whenever an attendee client requests a connection, the host will get this message asking for approval:

{
  "type": "verify-attendee-request",
  "clientId": "$clientId",
  "code": "$code"
}

If you deem the provided code worthy, accept the request:

{
  "type": "accept-attendee-request", 
  "clientId": "$clientId"
}

Otherwise, decline it:

{
  "type": "decline-attendee-request", 
  "clientId": "$clientId"
}

Obtain the Start Board State

Once the handshake is complete, the server will emit a match message containing the starting FEN:

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

Clone this wiki locally