Course lesson 43 · Advanced Durable Objects

Realtime link clicks with Websockets

One study unit · Read, recall, then practice · Original video 00:17:32

The tracker now uses an alarm to batch clicks before broadcasting them to connected browsers. Each new click is stored, and if no alarm exists one is scheduled roughly two seconds ahead; the alarm queries a bounded recent set, sends it, advances offsets, and removes older rows. The instructor verifies the full redirect-to-map flow using local clicks, a Malaysia VPN location, and a phone.

Primary source: course video 43 · Supplied English subtitles · 00:17:32.

Understand the idea

What the course does

  1. Set an alarm only when one is not already scheduled, using a two-second target.
  2. Load offset state during object initialization, defaulting missing values to zero.
  3. Create a parameterized query helper for clicks after an offset, with a default result limit of 50.
  4. On alarm, query recent clicks and broadcast the click array to all connected sockets.
  5. Persist updated boundary times and delete records older than the retained boundary.
  6. Temporarily connect the frontend to the deployed secure socket, test geographic clicks, then restore host configuration.

Watch for

Recall before revealing

Why send the batch before performing cleanup?

Reveal the explanation

The lesson prioritizes getting the selected clicks to viewers promptly, then updates offsets and trims retained history.

Try it

Walk through a burst of 200 clicks with a 50-record query limit and explain the map’s purpose.

Check your result

You describe bounded visualization and identify the separate queue path instead of claiming all 200 clicks must appear individually.

Practice prompts and answer checks are added teaching material. Answer from memory first, then compare and explain any difference.

Rewatch only what you need

Open this lesson in your original course library and seek to the times below. Videos are not hosted on this site.

Companion primary documentation: Durable Objects WebSockets. For recorded API names, commands, limits, and prices, check the version you use.

← Previous   Next →