BarrageStore provides a complete set of barrage management APIs, including sending text barrages, sending custom barrages, and adding local tip messages. Through this class, you can implement barrage interaction functionality in live rooms.BarrageStore instance, which requires a valid live room ID.Property | Type | Description |
messageList | Barrage message list of the current room, supports real-time updates and can be subscribed to. |
Function | Description |
Create barrage management instance. | |
Add barrage event listener to receive custom messages. | |
Remove barrage event listener. | |
Send text barrage. | |
Send custom barrage. | |
Add local tip message. |
static BarrageStore create(String liveID) {return StoreFactory.shared.getStore<BarrageStore>(liveID: liveID);}
Parameter | Type | Required | Description |
liveID | String | Required | Live room ID. |
void addBarrageListener(BarrageListener listener);
Parameter | Type | Required | Description |
listener | Required | Barrage event listener instance. |
void removeBarrageListener(BarrageListener listener);
Parameter | Type | Required | Description |
listener | Required | Barrage event listener instance to be removed. |
Future<CompletionHandler> sendTextMessage({required String text,Map<String, String>? extensionInfo,});
Parameter | Type | Required | Description |
text | String | Required | Text barrage content. |
extensionInfo | Map<String, String>? | Required | Extension information, can contain custom fields (such as specifying barrage color, font size, etc.). |
Future<CompletionHandler> sendCustomMessage({required String businessID,required String data,});
Parameter | Type | Required | Description |
businessID | String | Required | Business identifier ID, used to distinguish custom barrages from different business scenarios. |
data | String | Required | Custom data content, usually JSON format string, used to pass business custom data. |
void appendLocalTip(Barrage message);
Parameter | Type | Required | Description |
message | Required | Local barrage message (such as system tips, operation feedback, etc., visible only to the current user). |
Enum Value | Value | Description |
text | 0 | Text type barrage, contains plain text content. |
custom | 1 | Custom type barrage, supports business custom data format (such as barrages with special effects, interactive messages, etc.). |
Property | Type | Description |
liveID | String | Unique identifier ID of the live room/voice chat room the barrage belongs to. |
sender | LiveUserInfo | User information of the barrage sender (such as user ID, nickname, avatar, etc.). |
sequence | int | Unique sequence ID of the barrage message, used for message sorting and deduplication. |
timestampInSecond | int | Barrage sending timestamp (unit: seconds), used to display sending time order. |
messageType | Barrage message type (text or custom). | |
textContent | String | Message content of text type barrage, i.e., the text content of the barrage. |
extensionInfo | Map<String, String> | Barrage extension information, customizable fields (such as display style, priority, etc.). Valid when messageType is TEXT. |
businessID | String | Business identifier ID of custom type barrage, used to distinguish custom barrages from different business scenarios. |
data | String | Specific data content of custom type barrage (usually JSON format string), valid when messageType is CUSTOM. |
Property | Type | Description |
messageList | Barrage message list of the current room, supports real-time updates and can be subscribed to. |
Property | Type | Description |
onCustomMessageReceived | void Function(Barrage)? | Callback triggered when a custom barrage message is received. |
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback