0
Once upon a time it was popular to put a counter on your web page, to
show how many people had visited the site before you. I thought it be
more fun, and less bragging about how long the page has existed, if it
just showed who’s reading it now.
As I mentioned in a previous post, I’m learning Rust. My teaching
project has been to make this web widget that shows the current number
of browsers that that have the page open.
You see this counter here on the blog in the top right.
The idea is pretty simple. Have some javascript open a websocket to a
server, and stream down messages with the current count, as it
changes. When a client connects or disconnects, inform all other
clients of the new total.
This does mean that it needs to keep one TCP connection open per
client, which may be too costly for some sites. Especially since I’m
putting it behind an nginx, so the machine needs to keep 3x the state.
I’m not logging anything to disk, nor sharing anything between the
clients except for the current count. It’s just an amusing publicly
visible presence counter.
Actually, because Continue reading