|
|
|
|
|
by Ndymium
1873 days ago
|
|
Here's the relevant part from the article: > The browser click triggers an event in the player's LiveView. There is a bi-directional websocket connection from the browser to LiveView. > The LiveView process sends a message to the game server for the player's move. > The GameServer uses Phoenix.PubSub to publish the updated state of game ABCD. > The player's LiveView is subscribed to notifications for any updates to game ABCD. The LiveView receives the new game state. This automatically triggers LiveView to re-render the game immediately pushing the UI changes out to the player's browser. So you can see that when Player 1 does an action, the action is sent to the GameServer. Player 1's UI is only updated when the GameServer has published the new game state via PubSub back to Player 1's LiveView process, that pushes it onto the client. So there is the latency of going from client to LV to GameServer and back again, but there is no race possibility. |
|