本文档 API 接口为最新版本接口,后续相关功能的新增都会在此更新,推荐使用最新版本接口。旧版接口文档请参考历史版本。
在你的音视频应用中,当你需要从业务服务端,向指定 RTC 房间内的批量用户发送点对点消息时,你可以使用 BatchSendRoomUnicast 这个 OpenAPI 实现这一功能。
你可以调用 BatchSendRoomUnicast 接口,指定你所属的 AppId,向 roomId 对应的房间内指定用户批量发送点对点消息。
注:
- 消息可以是文本消息,也可以是二进制消息。
- 文本消息大小不能超过 20 KB,二进制消息大小不能超过 20 KB。
- 该接口支持单次最多同时给600个用户发送点对点消息。
消息发送成功后,用户会通过以下回调收到该消息:
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
请求频率:对于每个 AppId,调用 SendUnicast、SendRoomUnicast、SendBroadcast与BatchSendRoomUnicast的频率上限之和是 500 次每秒。
下表仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数。
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | String | 是 | BatchSendRoomUnicast | 接口名称。当前 API 的名称为 BatchSendRoomUnicast。 |
| Version | String | 是 | 2023-07-20 | 接口版本。当前 API 的版本为 2023-07-20。 |
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| AppId | String | 是 | Your_AppId | 应用的唯一标志 |
| RoomId | String | 是 | Your_RoomId | 房间 ID,是房间的唯一标志 |
From | String | 是 |
| 业务服务端的唯一标识。 |
| To | Array of 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
}
json{
"ResponseMetadata": {
"RequestId": "Your_RequestId",
"Action": "BatchSendRoomUnicast",
"Version": "2020-12-01",
"Service": "rtc",
"Region": "cn-north-1"
},
"Result":{
"Message": "Success"
}
}
json您可访问公共错误码,获取更多错误码信息。