I am planning to make a simple game using Phoenix LiveView. Originally I want to store game states directly into database but after watching Chris Mccord video I decided to use GenServer (I also want to practice and get used to OTP) to store the state.
My simple game flow:
- A user can create a game room, the created room will be visible in the home page (more like a lobby).
- When another use click that room, he will be added to the current participants in that room.
- The creator then starts the game when everyone is ready.
I get how GenServer works when it is not using the phoenix framework. I just run the GenServer module in the terminal, get the pid by pattern matching and perform GenServer calls.
In phoenix application I don’t understand how do each user (who joins a room) assign a pid that can be later be used to call GenServer functions.
If my application is not understandable, kindly tell me.
Thank you and hope somebody could help me.