Chat, gifts and likes
Send chat, app messages such as gifts, and likes in a voice room.
The kit's chat list and input work with no code. This page covers sending from code, and how messages travel.
Room messaging
When room messaging is on for your project, the token response includes room_messaging, and the kit sends chat, app messages and likes through the engine's room socket. The engine orders them (app messages, then host and admin chat, then other chat), limits visible chat per room, and batches everything together. A busy room stays readable and light on the network.
If your project doesn't use it, or the socket is down, chat and app messages use the data channel instead. Your code doesn't change either way.
Send a gift or other app message
final ok = await controller.sendRoomMessage({'type': 'gift', 'gift_id': 7});
if (!ok) {
// The engine refused it: too fast, or the room is busy.
}Messages arrive on dataStream with the same payload.
Likes
controller.sendLike(); // taps are summed for you
controller.likeCount.addListener(() {
// the room total
});
controller.likeStream.listen((n) {
// animate n likes
});sendLike() returns false when room messaging isn't available.
See which path is active
controller.roomMessagingActive.addListener(() {
// true while chat, gifts and likes go through the engine
});Send chat
await controller.sendChatMessage('Hello');