samedi 15 août 2020

Pattern to synchronize backend, Javascript and DOM state

Being relatively new to the web world, I encountered a (pretty common?) problem.

Developping a multiplayer game, I'm having trouble handling disconnections. Server and clients communicate through websockets, so whenever a client is disconnected, he misses on the notifications sent by the other clients (routed by the server). Which means that :

  • whenever a client is disconnected, I need to record all changes happening afterwards.
  • when he connects back, I need to send him all this info
  • the client then needs to be able to replay these records to sync with the server state.

I was wondering if there was some kind of design pattern to handle this problem (rather than an implementation specific solution). I believe it's kind of what React, Vue etc... are meant for (?), but I'd rather avoid using any heavy framework.

Any ressource/doc would also be appreciated ;)

Aucun commentaire:

Enregistrer un commentaire