Demo link is in the readme if you want to try it.
I always wanted to build something realtime-ish for the web that multiple people can use simultaneously. I was wondering how such systems could work and how hard the realtime part would be.
Here I'm using Postges listen/notify to let my rust service know when tables change without having to query these tables all the time. First I was using one listener for every websocket connection. But a listener keeps a postgres connection hostage, so it would cause problems with too many clients holding a WS connection.
Next thing I tried was to have just one listener and send updates to the websocket handler via a mpmc channel. But the channel receivers remove messages from the channel once they read them. Thats unfortunate since changes in a game of bingo are relevant to all players. Meaning that only one random receiver reading the update for a game would be bad for the other players.
Now I'm using a channel type from the tokio library called "watch". It contains just one value and receivers can await changes and don't remove the value from a channel on reading it. That allows broadcasting changes to all receivers so that all players getting realtime updates about the game.
Next I might look into WebRTC DataChannels to send game updates from client to client without the server in between (mostly).
Is someone else working on a similar problem and has repos to recommend?
Thanks!
Besides that, i never have seen a strong stack for a simple game. This is really impressive.
Kudos