We want each new game to be supervised. That means that we need the GameSupervisor process to start them. As the GameSupervisor process starts new game processes, under the hood it will link to them and trap exits so that it can receive ordinary messages if any of the games should crash.
Let’s start by adding a public start_game/1 function in the GameSupervisor module to start games with. Once we have the supervisor starting the processes, it will take care of the rest for us.
|||def start_game(name), do:|
Here’s what happens when we call start_game/1:
__MODULE__ here evaluates to GameSupervisor, which is the local ...