You need to enable JavaScript to run this app.
导航

批量发送房间内点对点消息 BatchSendRoomUnicast

最近更新时间2024.02.29 19:30:23

首次发布时间2022.03.17 14:46:20

在你的音视频应用中,当你需要从业务服务端,向指定 RTC 房间内的批量用户发送点对点消息时,你可以使用 BatchSendRoomUnicast 这个 OpenAPI 实现这一功能。

使用说明

接口行为

你可以调用 BatchSendRoomUnicast 接口,指定你所属的 AppId,向 roomId 对应的房间内指定用户批量发送点对点消息。

注:

  • 消息可以是文本消息,也可以是二进制消息。
  • 文本消息大小不能超过 20 KB,二进制消息大小不能超过 20 KB。
  • 该接口支持单次最多同时给600个用户发送点对点消息。

消息发送成功后,用户会通过以下回调收到该消息:

AndroidiOSWindows
文本消息onUserMessageReceivedrtcEngine:onUserMessageReceived:messageOnUserMessageReceived
二进制消息onUserBinaryMessageReceivedrtcEngine:onUserBinaryMessageReceived:messageOnUserBinaryMessageReceived

调用接口

关于调用接口的请求结构、公共参数、签名算法和返回结构,参看调用方法

注意事项

请求频率:对于每个 AppId,调用 SendUnicastSendRoomUnicastSendBroadcastBatchSendRoomUnicast的频率上限之和是 500 次每秒。

请求说明

  • 请求方式:POST
  • 请求地址:https://rtc.volcengineapi.com?Action=BatchSendRoomUnicast&Version=2020-12-01

请求参数

下表仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数

Query

参数名称
数据类型
是否必选
示例值
描述
Action
String
BatchSendRoomUnicast
接口名称。当前 API 的名称为 BatchSendRoomUnicast
Version
String
2020-12-01
接口版本。当前 API 的版本为 2020-12-01

Body

参数
类型
是否必选
示例值
描述
AppId
String
Your_AppId
应用的唯一标志
RoomId
String
Your_RoomId
房间 ID,是房间的唯一标志
From
String
from_userid
业务服务端的唯一标识。
命名规则符合正则表达式:[a-zA-Z0-9_@\-\.]{1,128}
在一个 AppID 下,不能和真实用户用于实时消息通信的 user_ID 重复;
建议使用固定的 ID 的发送消息。
To
String[]
[user1, user2]
消息接收者的 user_ID
Binary
Boolean
FALSE
是否为二进制消息。
Message
String
hello
点对点消息 。如果是二进制消息,需进行 base64 编码

返回参数

下表仅列出本接口特有的返回参数,公共返回参数请参见返回结构

参数
类型
示例值
描述
Message
String
success
仅在请求成功时返回消息 Success,失败时为空。

请求示例

POST https://rtc.volcengineapi.com?Action=BatchSendRoomUnicast&Version=2020-12-01
{ 
    "AppId" : "Your_AppId",
    "From" : "from_userid",
    "To" : ["user1", "user2"],
    "RoomId" : "Your_RoomId",
    "Message" : "your message",
    "Binary" : false
}

返回示例

{
    "ResponseMetadata": {
        "RequestId": "Your_RequestId",
        "Action": "BatchSendRoomUnicast",
        "Version": "2020-12-01",
        "Service": "rtc",
        "Region": "cn-north-1"
    },
    "Result":{
        "Message": "Success"
    }
}

错误码

您可访问公共错误码,获取更多错误码信息。