2 pointsby explosionpunch5 hours ago2 comments
  • robinvdvleuten3 hours ago
    This is a neat LiveView use case. The bit that jumped out to me is "each game as its own process", which feels very BEAM-y in the good way.

    Curious how you're handling abandoned games. Do they just sit around until some timeout kills them, or are you persisting after each move so they can be rebuilt after a deploy/restart?

    • explosionpunch2 hours ago
      Thanks! I should have been more precise and said that each player's LiveView socket is a separate process, and each game is a PubSub topic. But yes, games are persisted in a database after each move so you can close the window, come back later, re-join on your phone, etc, just like you'd be able to do on chess.com. So games that are abandoned currently stick around in the database, but don't keep a long-running process up unless someone actually has their browser open the whole time. Games with a timer (regular games that were started with a per-move timer and all tournament games) eventually time out in a loss for the player who let the clock run out, but those stick around as well - you can view replays of any finished game.

      Deploys and restarts don't impact too much - sockets just reconnect and the state reloads from the db.

  • explosionpunch5 hours ago
    [dead]