In part 3 we build more of the server. We build out the functionality to receive messages, then distribute them to all connected users.
For this part we use Trio’s nurseries to start up new running tasks: https://trio.readthedocs.io/en/stable/reference-core.html#nurseries-and-spawning
We use the
nursery.start_soon() function to kick off new tasks in the background.
The other tool we use another tool from Trio, the memory channels: https://trio.readthedocs.io/en/stable/reference-core.html#using-channels-to-pass-values-between-tasks
For this we use the
trio.open_memory_channel() function to create a channel and get a send+receive channel, which we then use to distribute the messages between connected users.
Got any questions? Contact me: https://jaytuckey.name/about/