Idea: persist liveview state across reconnections

For game maybe you could create something similar to Microsoft Orleans Virtual actors with processes? I mean like start a GenServer for the game logic that keeps the state and then just pass reference id to that game process to the client and maybe put some info into database that user has access to that game into database or maybe encode it’s id into a JWT token? That game state could then live even in another server. So if you connect to server1 you could just message game state running on server2 where it was originally started. Then that game state could have timeout that makes it die after certain time passes after no keep alive messages. In this case you should only keep minimal game state information in LiveView’s process. Benefit from this is that you could even have multiple LiveViews connecting to same game.

For AI I think that highly depends on what kind of AI data how much. If it’s images you probably store it somewhere anyway and just provide a link.

2 Likes