Skip to the guide

Presence: who's online

IntermediatePattern5 pages

A big office has an in/out board in the lobby with a magnet for everyone. The receptionist at each entrance moves a magnet when someone arrives, and moves it to "out" only once she hasn't seen that person for a while, so a coffee break changes nothing. Colleagues glance at the board when they want someone, instead of being phoned whenever anyone comes or goes, and each receptionist keeps a light on the board lit while she's at her desk.

Staff are users, the receptionists are gateways, and seeing someone through the glass is the phone's heartbeat. The board is the presence store in Redis, a moved magnet is the gateway's write, and the receptionist's light is a liveness key the gateway keeps renewing. A glance at the board is a phone reading status for the chat on its screen. Interviewers listen for how you know someone left without saying goodbye, and what showing it costs. The move: let the gateway that holds a connection be the only writer, write only when the status changes, and push changes only to the phones that are showing them.