GizStack
View .mdOpen in ChatGPTOpen in Claude

gizweb:presence

Who is in a room now: each person renews a lease with a heartbeat, and a person whose lease ended is gone.

gizlang
import * as Presence from "gizweb:presence";

Types

Presence

gizlang
type Presence = { @Key room: string; @Key person: string; expires: i64; }

PERSON's lease in ROOM, which ends at expires (ms).

  • room: string
  • person: string
  • expires: i64

Functions

install

gizlang
function install(d: Data.Db): bool throws Model.Rejection

Makes the presence table when it is not there.

Effects: fail, read, write, console, io.

beat

gizlang
function beat(d: Data.Db, room: string, person: string, expires: i64): bool throws Model.Rejection

Renews PERSON's lease in ROOM until EXPIRES.

Effects: fail, read, write, console, io.

present

gizlang
function present(d: Data.Db, room: string, now: i64): Vec<string> throws Model.Rejection

The people in ROOM at NOW, ordered by id.

Effects: fail, read, write, console, io.