PP.Chat

Manage chat rooms and message history with built-in room abstraction and optional persistence.

Rooms

Create named rooms and join/leave from clients. The server tracks room membership and can broadcast to a room.

server.chat.room('lobby').on('join', (client) => {
  client.send({ type: 'system', text: 'Welcome to lobby' });
});

// Client
client.chat.join('lobby');
client.chat.send('lobby', { text: 'Hello' });

History

Optional in-memory or persisted history per room. New joiners can request the last N messages for catch-up.

server.chat.room('lobby', { history: 100 });

// Client: get last 50 messages on join
client.chat.history('lobby', 50).then(messages => {
  console.log(messages);
});

See PP.Media for file and thumbnail handling in chat.