increaseGroupCounter static method
Implementation
static Future<V2TimValueCallback<Map<String, int>>> increaseGroupCounter({
required String groupID,
required String key,
required int value,
}) async {
String userData = Tools.generateUserData();
Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
Pointer<Uint8> keyPtr = Tools.string2PointerInt8(key);
Pointer<Uint8> groupIDPtr = Tools.string2PointerInt8(groupID);
int res = desktopSDK.D_TIMGroupIncreaseGroupCounter(groupIDPtr, keyPtr, value, user_data);
if (res != TIMResult.TIM_SUCC) {
return V2TimValueCallback<Map<String, int>>.fromJson({
"code": res,
"desc": "",
"data": Map.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,
});
}
}