# Online parties and voice chat in PlayDrop games

Let friends play together online: declare party sizes, open PlayDrop's party window, join reserved rooms with sdk.multiplayer.join and control room voice.

Source: https://www.playdrop.ai/create/learn/online-party

A PlayDrop party is a group of friends that moves between games together. When a party starts your game, PlayDrop reserves seats for its members in one of your server's rooms, so friends arrive in the same match instead of being split up. Voice chat runs in PlayDrop, not in your game.

## What you need

- A [realtime game server](https://www.playdrop.ai/create/learn/game-servers): parties play in your Colyseus rooms.
- Signed-in players: rooms refuse guests.
- These declarations in [catalogue.json](https://www.playdrop.ai/create/learn/catalogue-json):

```json
{
  "types": ["solo", "online", "party"],
  "party": { "online": [2, 3, 4] },
  "roomVoice": true,
  "server": { "entry": "server/index.mjs", "rooms": ["game"] }
}
```

`party.online` lists the exact group sizes, up to 4, that may arrive together; `[2, 4]` excludes 3. It is the size of the arriving group, not the room capacity: two parties of four can share an eight-seat room. `party` requires the `party` type and `party.online` requires `online`. `roomVoice: true` turns on room voice and requires `online`.

## Join the right room

```js
if (!sdk.me.isLoggedIn) {
  await sdk.me.promptLogin();
}
const room = await sdk.multiplayer.join("game", { mode: "versus" });
```

`join` consumes the player's reserved party seat when PlayDrop launched a party, and otherwise joins independently. If a party join fails it rejects; it never silently puts the player in a different room. A guest gets `authentication_required` and PlayDrop shows sign-in; join again from `sdk.me.onAuthChange`. Keep the same room across rounds.

After a reload, `sdk.multiplayer.reconnect(roomName, token)` restores the reserved seat with a reconnection token you stored privately for this game, version and user. Discard the token and call `join` on `multiplayer_reconnect_expired`, `multiplayer_reconnect_unavailable` or `party_reconnect_mismatch`.

## The party window

From a button, `sdk.social.openParty({ mode: "online" })` opens PlayDrop's party window, where players invite friends and turn voice on or off. An existing party is reused. `openParty()` opens the party menu and `openParty({ section: "voice" })` opens voice settings; do not combine `mode` and `section`. The promise resolves when the window closes, including on cancel.

Read the party with `sdk.social.getParty()` or `sdk.social.onPartyChange(callback)`, which delivers the current state first: `{ partyId, leaderUserId, revision, members, launch }`. `launch.status` is `joining` or `ready` when the party is playing this game. Membership alone does not mean the players share a room; use `join`.

Party membership belongs to PlayDrop: games cannot add or remove party members or control microphones, and players invite friends to the party from this window. A game can still send its own invite or challenge card to a friend with `sdk.social.sendMessage`; see [sharing, friends and invites](https://www.playdrop.ai/create/learn/social).

## Room voice

With `roomVoice: true`, everyone in a room can talk, with no server code. To change who hears whom, bind the room on your server and set a policy:

```js
import { playdrop } from "@playdrop/server";

const platform = playdrop.multiplayer.forRoom(this);
platform.voice.setPolicy("team");
platform.voice.setTeam(client.auth, "red");
```

Policies are `all`, `team`, `proximity` (with `{ range }`) and `off`. `setAudience(player, audience)` overrides one player and `updatePositions([{ player, position: { x, y, z } }])` feeds proximity; pass `null` to clear a team or override. PlayDrop enforces who may hear whom. In the browser, `sdk.multiplayer.voice.updateSpatialState({ listener: { position, forward, up }, speakers: [{ userId, position }] })` only adjusts volume and panning.

Voice is subject to player consent, mute and blocks, and depends on the host build and rollout.

## Pausing

The party capsule does not pause gameplay. PlayDrop's pause stops your client, but the room stays connected and your server keeps running. One player's pause must not stop the match for others; implement any match pause on the server.

## Test

Upload a private version, then open the test link in two windows with `player=1` and `player=2`, as described in [realtime game servers](https://www.playdrop.ai/create/learn/game-servers). Local parties with controllers are a separate mode: see [local parties and controllers](https://www.playdrop.ai/create/learn/local-party).

## Related guides

- [Realtime game servers](https://www.playdrop.ai/create/learn/game-servers): Run a hosted Colyseus 0.17 server with a MongoDB database for your game, connect from the browser with the SDK, test with two players and know the limits.
- [Local parties and controllers](https://www.playdrop.ai/create/learn/local-party): Read physical gamepads and PlayDrop phone controllers through sdk.device, follow local player slots, declare controller support and local party sizes.
- [Sharing, friends and invites](https://www.playdrop.ai/create/learn/social): Share a game with an image or clip, read launch payloads, pick friends, send invite and challenge cards in PlayDrop Chat, and recommend other games.
