Running multiplayer game loop with django channels

Minor points:

Yes, this is absolutely correct.

There is no “main” process. It’s not like any one process controls or manages other processes. They’re all “peers” within the environment.

The processes can be defined (in this context) by where it receives input from and where it delivers output.

Using that definition, the processes then are:

  • Websocket consumer (async)

    • Input: Websockets, channel_layer
    • Output: Websocket, channel_layer
  • Game worker(s) (sync)

    • Input: Channel_layer
    • Output: Channel_layer
  • Timer worker (async)

    • Input: Channel_layer, timer events
    • Output: Channel_layer

(While I believe we’re on the same page, I want to reduce the chances of confusion. We may be saying the same thing different ways, but I’d like to try to make sure that’s the case here.)

One of the benefits of splitting these functions into separate processes is that it minimizes (if not effectively eliminates) the possibility of a game worker from interfering with either the websocket consumer or the timer worker. (You want to avoid having game updates from preventing a timer signal from being triggered at the proper time.)

1 Like