cloudflare / cloudflare/partykit
Joining multiple rooms proxy?
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
Any example how can I join multiple rooms? For example, an admin with 10 websites needs to join 10 rooms created to [embed the chat bot on his websites](https://github.com/ticketdesk-ai/ticketdesk-chat).
So, if I send a request to `/chatroom/all-rooms`, I need
```
const socket = usePartySocket({
host: "localhost:8787",
party: "chatroom",
room: "all-rooms",
});
```
```
app.use(
"*",
partyserverMiddleware({
options: {
onBeforeConnect: async (req) => {
const token = req.headers.get("authorization");
// Validate token
if (!token) return new Response("Unauthorized", { status: 401 });
// Get room names and join all
if(req.url.endsWith('all-rooms'))
const rooms : string[] = await getRooms(userId, token)
?? proxy to all chatroom/room1
// chatroom/room1
// chatroom/room2
}
}
})
);
```
Contributor guide
Assessment
This issue has not been assessed yet.