Skip to content

Rooms

This documents the old v1 API. See Actors for the current version.

Rooms group clients for targeted broadcasting.

.incoming(({ send }) => ({
joinRoom: zo.message
.input(z.object({ roomId: z.string() }))
.handle(({ ctx, input }) => {
ctx.rooms.join(input.roomId);
})
}))
ctx.rooms.leave("room-123");
if (ctx.rooms.has("admin-room")) { /* ... */ }
send.chat.message({ text: "hello" }).toRoom(["room-123"]);