-
Notifications
You must be signed in to change notification settings - Fork 0
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):
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"
}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"
}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"
}Once the handshake is complete, the server will emit a match message containing the starting FEN:
{
"type": "matched",
"fen": "$fen"
}