音视频通话

房间内成员自定义属性

功能介绍

房间内成员自定义属性用于在成员维度存储业务侧需要的键值信息,例如头像地址、身份或权限标记等。同一房间内的成员属性是共享的,可以互相获取。

本模块提供完整的生命周期能力:设置指定成员的整包属性、查询(支持批量成员)全部属性或指定键、增量添加或更新、按键删除、清空指定成员全部属性,以及清空当前房间内所有成员的全部属性;各操作通过异步接口发起,结果在对应回调中返回。属性发生变更时,还可通过通知接口获知更新(详见 onNotifyUserAttrsChanged)。

下文按典型操作分节说明接口调用与对应回调,各小节末尾列出相关 API 链接。

1.设置成员属性

  • 调用接口:
string userID = "111";
Map<String, String> attrs = {
	"name": "Bob",
	"companyName": "ABC"
};
Map<String, Object> options = {}
CommonResult result = await RtcSDK.attributeManager.setUserAttrs(userID, attrs, options)

相关API请参考:

2.获取指定成员全部属性

  • 调用接口:
String userIDs = ["userID"];
List<String> keys = [];
MeetingAttrResult result = await  RtcSDK.attributeManager.getUserAttrs(userIDs, keys);

相关API请参考:

3.获取指定成员指定属性

  • 调用接口:

String userIDs = ["userID"];
List<String> keys = ["CompanyName"];
MeetingAttrResult result = await  RtcSDK.attributeManager.getUserAttrs(userIDs, keys)

相关API请参考:

4.添加或更新指定成员指定的属性

  • 调用接口:


String userID = "userID";
Map<String, String> attrs = {
	name: "Bob",
};
CommonResult result = await RtcSDK.attributeManager.addOrUpdateUserAttrs(userID, attrs)

相关API请参考:

5.删除指定成员的指定属性

  • 调用接口:
String userID = "userID";
List<String> keys = ["CompanyName"];
CommonResult result = await RtcSDK.attributeManager.delUserAttrs(userID, keys)

相关API请参考:

6.清除指定成员全部属性

  • 调用接口:

String userID = "userID";
Map<String, Object> options = {}
CommonResult result = await RtcSDK.attributeManager.clearUserAttrs(userID, options);

相关API请参考:

7.清除当前房间内所有成员全部属性

  • 调用接口:

Map<String, Object> options = {}
CommonResult result = await RtcSDK.attributeManager.clearAllUserAttrs(options);

相关API请参考: