getGroupCounters static method
Implementation
static Future<V2TimValueCallback<Map<String, int>>> getGroupCounters({
required String groupID,
required List<String> keys,
}) async {
String userData = Tools.generateUserData();
Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
Pointer<Uint8> keysPtr = Tools.string2PointerInt8(json.encode(keys));
Pointer<Uint8> groupIDPtr = Tools.string2PointerInt8(groupID);
int res = desktopSDK.D_TIMGroupGetGroupCounters(groupIDPtr, keysPtr, user_data);
if (res != TIMResult.TIM_SUCC) {
return V2TimValueCallback<Map<String, int>>.fromJson({
"code": res,
"desc": "",
"data": Map<String, int>.from({}),
});
} else {
Map<String, dynamic> data = await getAsyncData(apiKey: userData);
List<Map<String, dynamic>> dataList = List<Map<String, dynamic>>.from(json.decode(data["json_param"].isEmpty ? json.encode([]) : data["json_param"]));
Map<String, int> couner = Map.from({});
for (var i = 0; i < dataList.length; i++) {
var item = dataList[i];
couner[item["group_counter_key"]] = item["group_counter_value"];
}
return V2TimValueCallback<Map<String, int>>.fromJson({
"code": data["code"],
"desc": data["desc"],
"data": couner,
});
}
}