TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Multiplayer bullshit bingo using WebSockets, Postgres notify and rust

12 pointsby jflessaualmost 3 years ago

2 comments

jflessaualmost 3 years ago
A realtime multiplayer bullshit bingo game with prefilled or custom bingo cards for things like online meetings or apple keynotes.<p>Demo link is in the readme if you want to try it.<p>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.<p>Here I&#x27;m using Postges listen&#x2F;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.<p>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.<p>Now I&#x27;m using a channel type from the tokio library called &quot;watch&quot;. It contains just one value and receivers can await changes and don&#x27;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.<p>Next I might look into WebRTC DataChannels to send game updates from client to client without the server in between (mostly).<p>Is someone else working on a similar problem and has repos to recommend?<p>Thanks!
评论 #32555141 未加载
phpisatrashalmost 3 years ago
Wow. Well done. Great work. That&#x27;s what I call overqualification for a work.<p>Besides that, i never have seen a strong stack for a simple game. This is really impressive.<p>Kudos