Chat
Talk to players as the host, and send styled announcements.
All chat is literal text. HTML, CSS and markup are shown as typed, and player messages can't look like announcements. Each player's own display settings, such as chat position and sounds, stay under their control.
sendChat()
room.sendChat(text: string, targetId?: number | null): Promise<void>Sends a chat message as the host player. It requires a host player: with noPlayer: true it rejects with sendChat requires a host player; use sendAnnouncement. A targeted message goes to that player's chat log only; a message to an unknown or departed player is dropped. Your own messages do not trigger onPlayerChat.
Parameters
stringrequirednumber | nullnull to send to everyone.Returns
Promise<void>
await room.sendChat('Good game, everyone!');
await room.sendChat(
'You are next in goal.',
player.id,
);sendAnnouncement()
room.sendAnnouncement(text: string, targetId?: number | null, color?: number | null, style?: AnnouncementStyle | null, sound?: number | null): Promise<void>Literal text, up to 1,000 characters. RGB color 0x000000–0xffffff; null target broadcasts. Sound 0/1/2 is subject to recipient preferences.
Posts a host notice that stands apart from player chat. Works in rooms without a host player.
Parameters
stringrequirednumber | nullnull to announce to everyone.number | null0x000000 to 0xffffff, or null for the reader’s default. Pick colors that read well on a dark chat.AnnouncementStyle | nullnormal, bold, italic, small, small-bold or small-italic. Defaults to normal.number | null0 silent, 1 normal or 2 alert. Defaults to 1. Each reader’s sound settings still apply.Returns
Promise<void>
await room.sendAnnouncement(
'Welcome to the room',
null,
0xb9e8d0,
'bold',
0,
);
await room.sendAnnouncement(
'Your request was accepted',
player.id,
0xefc88e,
'small',
1,
);