Server APIs v2
  • Server APIs overview
  • Accessing Server APIs
  • Room signaling
  • Stream mixing
  • Streaming moderation
  • Streaming control
  • Cloud recording
  • Server callbacks
  • Return codes
  • API testing

Send a Barrage Message

Last updated:2022-03-22 13:07

1 Description

Sends a text message to all users in a room without guaranteeing the message delivery. A typical use case is to use Barrage Messages for sending "bullet screen" messages.

On the client side, the ZEGO Express SDK will trigger the following callback when it receives a Barrage Message:

Platform ZEGO Express SDK callback
iOS/macOS onIMRecvBarrageMessage
Android onIMRecvBarrageMessage
Windows onIMRecvBarrageMessage
Web IMRecvBarrageMessage

2 Request method and endpoint

  • Request method: GET
  • Request endpoint: https://rtc-api.zego.im/?Action=SendBarrageMessage
  • Transmission protocol: HTTPS
  • Rate limit (Rooms with the same AppID): 100 requests/second (Testing environment: 10 requests/second)

3 Request parameters

Listed below are the parameters specific to this request and part of the public request parameters. For the complete list of public request parameters, see Server APIs public request parameters.

Parameter Type Required Description
RoomId
String
Yes
Room ID.
UserId
String
Yes
User ID of the message sender.
UserName
String
No
User name of the message sender.
MessageCategory
Int
Yes
Message type.
  • 1: System Message
  • 2: Chat Message
MessageContent
String
Yes
Message content, with a maximum length of 1024 bytes.

4 Request example

https://rtc-api.zego.im/?Action=SendBarrageMessage
&RoomId=123
&UserId=12323
&UserName=3212136
&UserName=323
&MessageCategory=2
&MessageContent=hello+zego+big+im-%E5%BC%B9%E5%B9%95%E6%B6%88%E6%81%AF
&<Public Request Parameters>

5 Response parameters

Parameter Type Description
Code
Number
Return code.
Message
String
Description of the request execution result.
RequestId
String
Request ID.
Data
Object
Returned data.
└ MessageId
String
Message ID.

6 Response example

{
    "Code":0,
    "Data":{
        "MessageId":"1_1611647493487_29"
    },
    "Message":"success",
    "RequestId":"2237080460466033406"
}

7 Return codes

Listed below are the return codes related to this API. For the complete list of return codes, see Return codes.

Return code Possible cause and solution
104 The room does not exist. (the detection logic is the same as the return codes 5024 and 50001.) Please check the RoomId.
206 The rate limit (requests per second) has exceeded the limit. Please adjust the frequency of your requests or contact ZEGOCLOUD technical support.
5018 Room status does not match. Please try again later.
5024 The room does not exist. (the detection logic is the same as the return codes 104 and 5001.) Please check the RoomId.
50001 The room does not exist. (the detection logic is the same as the return codes 104 and 5024.)
  • When there are no users in a room, the room will be automatically destroyed by the server.
  • When there is only one user in a room and the user exits or is kicked out of the room, the room will be automatically destroyed by the server.
  • When a room's heartbeat request times out by 100 seconds, the room will be destroyed by the server.
50002 User does not exist. Please check the UserId.
50003 Failed to query the user's online info. Please check whether the user is online based on the UserId.
50004 Failed to read the user info. Please check whether the user is online based on the UserId.
50009 Moderation failed. Please try again later or contact ZEGOCLOUD technical support.
50011 The number of recipients of the custom message has exceeded the limit.
50012 The length of the custom message has exceeded the limit.
50013 Failed to send custom messages. Please contact ZEGOCLOUD technical support.