FluxyChat

Rooms

Message history

PaginatedResult. newestFirst by default. fromSerial and beforeSerial.

const page = await room.messages.history({ limit: 50 });
for (const message of page.items) {
  console.log(message.id, message.text, message.serial);
}

if (page.hasNext()) {
  const older = await page.next();
}
ParamWhat it does
limitPage size
orderBynewestFirst (default) or oldestFirst
beforeISO timestamp, exclusive
fromSerialNumeric id, id > n
beforeSerialNumeric id, id < n
start / endTime window on createdAt

REST: GET /messages with the same bounds. The Worker does not speak MessagePack.

Versions of one line: room.messages.getVersions(id) reads room_message_events (REST PATCH also records an update).

If the socket resumes with a hole it cannot fill, you get onDiscontinuity (code 10200). Reload history from there. Cookbook: message history.