I've run into a couple race conditions around disconnection & reconnection that seems to leave API clients lost about the state of the opponent's presence.
To test these, you'll need to ability to temporarily disconnect an API-client while independently disconnecting and reconnecting a web-client. For this, I used an eBoard as my API-client, and chrome as my API-client. I connected the eBoard through a mobile hotspot on my phone so that I could turn it off and on quickly without restarting my router.
Steps to reproduce strangeness(1): no opponentGone:false after API-client reconnect:
- Start a game with API-client , and web-client
- during gameplay, close web-client
- wait for API-client to indicate
opponentGone:true - disconnect API-client by turning off hotspot
- while API-client is disconnected, reopen lichess.org game tab in web-client
- API-client reconnects to nginx, opens event-stream and receives
gameStart, opens game-stream and receivesgameState - I cannot seem to tell if web-client is online or not
Steps to reproduce strangeness(2): no opponentGone:false after web-client returns after disconnecting while API-client not connected:
- Start a game with API-client , and web-client
- during gameplay, close web-client
- wait for API-client to indicate
opponentGone:true - disconnect API-client by turning off hotspot
- API-client reconnects to nginx, opens event-stream and receives
gameStart, opens game-stream and receivesgameStateand receivesopponentGone:true - open lichess.org tab to reconnect web-client
- API-client stops receiving
opponentGone:true, but does not recieveopponentGone:false. API player cannot claim victory after the timeout.
Please also see closely related question: https://discord.com/channels/280713822073913354/1437538233616437424
Maybe there's a simple rule to follow regarding opponent presence detection using a combination of event packets? But it's not immediately clear to me.