HACKER Q&A
📣 olucurious

Any multiplayer game synchronisation experts on HN?


Hi game devs of HN. I'm building an app that lets you play html5 games while you video chat. My multiplayer games like checkers and Ludo keep losing state mid-game session but I noticed games like Poker with friends (https://cdn-factory.marketjs.com/en/poker-with-friends/index.html) & Ludo with friends don't have this problem no matter how many times I minimize the browser window.

My game communication interface currently uses websockets and engages a retry mechanism with message acknowledgement, so a message gets resent if the ack fails to arrive within a short period of time. Does anyone know how html5 online multiplayer games like those listed above maintain their state no matter what? can anyone see a problem with my websockets implementation?


  👤 jokethrowaway Accepted Answer ✓
I've built something similar and your architecture sounds just fine. With websocket you are able to send the state to the server and just share it across clients. Maybe you have clients disconnecting and reconnecting with a new id? You need to have a mechanism for identifying browsers (eg. storing something in localStorage)

Given you mention video chat, I wonder if you're relying on webrtc + websocket for signalling. In that case communication between clients would be p2p and a reconnection handled incorrectly could cause state to be lost.

But I'm just guessing.

HN is probably not the right place to get support for this though.


👤 sunbash
Not me. But you could try posting on r/gamedevs for some help maybe.