Game Servers in OTP

Game Servers in OTP

Given at ElixirConf 2014

64afebe5db598b0b043f35560bf940df?s=128

Martin Schürrer

July 26, 2014
Tweet

Transcript

  1. 3.
  2. 4.
  3. 5.
  4. 6.
  5. 7.

    Architecture big-picture The Table-FSM Life of an in-game event Real

    world concerns BoldPoker <3 Elixir Lessons Learned & QA
  6. 15.

    Architecture big-picture The Table-FSM Life of an in-game event Real

    world concerns BoldPoker <3 Elixir Lessons Learned & QA
  7. 16.
  8. 18.

    [ {DealCards, [cards_to_deal, :private]}, {Knocking, [5000]}, {DealCards, [cards_to_deal, :private]}, {Negotiation,

    []}, {Play, [contra_enabled: true]}, {Play, []}, {Play, []}, … {Play, []}, {Play, []}, {Result, []} ]
  9. 21.

    {:next_stage, new_stage_data, new_state_data} ! {:end_game, new_stage_data, new_state_data} ! Table.broadcast_event {:next_state,

    next_state_name, new_state_data} ! {:stop, reason, new_state_data} ! GenServer.reply Table.playing/2 -----> DealCards.playing/3
  10. 27.

    Architecture big-picture The Table-FSM Life of an in-game event Real

    world concerns BoldPoker <3 Elixir Lessons Learned & QA
  11. 35.

    P1 {Table,9} {Player,1} { "type": "playACard", "card": "XH" } {:game_event,

    {:play_card,{:ten,:hearts}} ProtocolJSON.parse/1
  12. 37.

    Architecture big-picture The Table-FSM Life of an in-game event Real

    world concerns BoldPoker <3 Elixir Lessons Learned & QA
  13. 51.

    P1 P2 P3 P4 {Table,9} P5 P6 P7 old new

    ConnectionProxy {TableMigrator,9}
  14. 54.
  15. 57.

    P1 2 3 4 old new { portable_state portable_state %{table_id:

     9,      player_ids:  [1,2,3,4],      positions:  %{1  =>  3,                                2  =>  0,                                3  =>  1,                                4  =>  2},      modifications:  [:short_hand],      last_game_id:  123   }
  16. 61.
  17. 62.
  18. 68.
  19. 70.

    Architecture big-picture The Table-FSM Life of an in-game event Real

    world concerns BoldPoker <3 Elixir Lessons Learned & QA
  20. 76.

    Architecture big-picture The Table-FSM Life of an in-game event Moving

    tables across servers BoldPoker <3 Elixir Lessons Learned & QA
  21. 77.

    Perform en/decoding at the system border P1 { "type": "playACard",

    "card": "XH" } {:game_event, {:play_card,{:ten,:hearts}} ProtocolJSON.parse/1 WS
  22. 78.

    Create your own behaviours for fun better reusability and profit

    easier testing {:next_stage, new_stage_data, new_state_data} {:end_game, new_stage_data, new_state_data}
  23. 80.

    DB failure? We got all data already, so finish the

    game, then just store result on disk