Skip to content

Joining multiple rooms proxy? #282

@vickyRathee

Description

@vickyRathee

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.

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
      }
    }
  })
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions