Rooms
This documents the old v1 API. See Actors for the current version.
Rooms group clients for targeted broadcasting.
Joining a Room
Section titled “Joining a Room”.incoming(({ send }) => ({ joinRoom: zo.message .input(z.object({ roomId: z.string() })) .handle(({ ctx, input }) => { ctx.rooms.join(input.roomId); })}))Leaving a Room
Section titled “Leaving a Room”ctx.rooms.leave("room-123");Checking Membership
Section titled “Checking Membership”if (ctx.rooms.has("admin-room")) { /* ... */ }Sending to a room
Section titled “Sending to a room”send.chat.message({ text: "hello" }).toRoom(["room-123"]);