makeCall method
void
makeCall()
Implementation
void makeCall() async {
if (selectedUsersJIDList.isEmpty) {
return;
}
var isOneToOneCall = selectedUsersJIDList.length == 1;
var isGroupCall = selectedUsersJIDList.length > 1;
if ((isGroupCall &&
!availableFeatures.value.isGroupCallAvailable.checkNull()) ||
(isOneToOneCall &&
!availableFeatures.value.isOneToOneCallAvailable.checkNull())) {
DialogUtils.showFeatureUnavailable();
return;
}
if ((await Mirrorfly.isOnGoingCall()).checkNull()) {
debugPrint("#Mirrorfly Call You are on another call");
toToast(getTranslated("msgOngoingCallAlert"));
return;
}
if (!(await AppUtils.isNetConnected())) {
toToast(getTranslated("noInternetConnection"));
return;
}
if (arguments.callType == CallType.audio) {
if (await AppPermission.askAudioCallPermissions()) {
if (isOneToOneCall) {
Mirrorfly.makeVoiceCall(
toUserJid: selectedUsersJIDList[0],
flyCallBack: (FlyResponse response) {
if (response.isSuccess) {
NavUtils.toNamed(Routes.outGoingCallView, arguments: {
"userJid": [selectedUsersJIDList[0]],
"callType": CallType.audio
});
} else {
DialogUtils.showAlert(
dialogStyle: AppStyleConfig.dialogStyle,
message: getErrorDetails(response));
}
});
} else {
Mirrorfly.makeGroupVoiceCall(
toUserJidList: selectedUsersJIDList,
flyCallBack: (FlyResponse response) {
if (response.isSuccess) {
NavUtils.toNamed(Routes.outGoingCallView, arguments: {
"userJid": selectedUsersJIDList,
"callType": CallType.audio
});
} else {
DialogUtils.showAlert(
dialogStyle: AppStyleConfig.dialogStyle,
message: getErrorDetails(response));
}
});
}
}
} else if (arguments.callType == CallType.video) {
if (await AppPermission.askVideoCallPermissions()) {
if (isOneToOneCall) {
Mirrorfly.makeVideoCall(
toUserJid: selectedUsersJIDList[0],
flyCallBack: (FlyResponse response) {
if (response.isSuccess) {
NavUtils.toNamed(Routes.outGoingCallView, arguments: {
"userJid": [selectedUsersJIDList[0]],
"callType": CallType.video
});
} else {
DialogUtils.showAlert(
dialogStyle: AppStyleConfig.dialogStyle,
message: getErrorDetails(response));
}
});
} else {
Mirrorfly.makeGroupVideoCall(
toUserJidList: selectedUsersJIDList,
flyCallBack: (FlyResponse response) {
if (response.isSuccess) {
NavUtils.toNamed(Routes.outGoingCallView, arguments: {
"userJid": selectedUsersJIDList,
"callType": CallType.video
});
} else {
DialogUtils.showAlert(
dialogStyle: AppStyleConfig.dialogStyle,
message: getErrorDetails(response));
}
});
}
}
}
}