groupCall method

  1. @override
Future<ActionCallback> groupCall(
  1. List<String> userIdList,
  2. String type,
  3. String? groupId
)
override

Implementation

@override
Future<ActionCallback> groupCall(
    List<String> userIdList, String type, String? groupId) async {
  if (_isListEmpty(userIdList)) {
    return ActionCallback(code: codeErr, desc: 'userIdList is empty');
  }
  if (!isOnCalling) {
    // 首次拨打电话,生成id,并进入trtc房间
    mCurRoomID = _generateRoomID();
    mCurCallType = type;
    _enterTRTCRoom();
  }

  // 过滤已经邀请的用户id
  List<String> filterInvitedList = [];
  for (var i = 0; i < userIdList.length; i++) {
    if (!mCurInvitedList.contains(userIdList[i])) {
      filterInvitedList.add(userIdList[i]);
    }
  }
  if (_isListEmpty(filterInvitedList)) {
    return ActionCallback(
        code: codeErr, desc: 'the userIdList has been invited');
  }
  mCurInvitedList = filterInvitedList;
  if (_isEmpty(groupId)) {
    var customMap = getCustomMap(isGroup: true);

    for (int i = 0; i < mCurInvitedList.length; i++) {
      V2TimValueCallback res = await timManager.getSignalingManager().invite(
          invitee: mCurInvitedList[i],
          data: jsonEncode(customMap),
          timeout: timeOutCount,
          onlineUserOnly: false);
          if(res.code == 0){
            mCurCallList.add({'userId': mCurInvitedList[i], 'callId': res.data});
          }

    }
    return ActionCallback(code: 0, desc: '');
  } else {
    mCurGroupId = groupId!;
    var customMap = getCustomMap(isGroup: true);
    V2TimValueCallback res = await timManager
        .getSignalingManager()
        .inviteInGroup(
            groupID: groupId,
            inviteeList: mCurInvitedList,
            data: jsonEncode(customMap),
            timeout: timeOutCount,
            onlineUserOnly: false);
            if(res.code == 0){
              mCurCallID = res.data;
    return ActionCallback(code: res.code, desc: res.desc);
            }
    return ActionCallback(code: res.code, desc: res.desc);
  }
}