At times, when sketches are more complex, it becomes necessary for every user in a sketch to interact with all the other users. However, there are situations when it's more logical to divide users into smaller clusters. To achieve this, p5.party employs room names to group users. Each designated room:

You set the room name when you call partyConnect().

Like app names, your room names should start with a letter and use only letters, numbers, and underscores. If your sketch uses multiple rooms they each need their own name, but it's okay for two different apps to use the same room name.

<aside> 🧟 Tip: Since multiple apps can have the same room names, its okay for room names to have general names like “main”. This also means that letting users provide their own room names is okay.

</aside>

Common Questions

  1. When do I use rooms?

    Most of the time, you will only have one room. It will probably have a name like “main”.

    If you might have a lot of players and need to divide them into groups, you can use rooms. See the select_room example to see one way of doing this.

  2. Can I let players select which room they go into?

    Yes, you can. Here’s an example for it.