You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
4.8 KiB
Dart
114 lines
4.8 KiB
Dart
import 'package:doctor_app_flutter/config/config.dart';
|
|
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
|
|
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
|
|
import 'package:doctor_app_flutter/core/service/patient/LiveCarePatientServices.dart';
|
|
import 'package:doctor_app_flutter/core/model/doctor/doctor_profile_model.dart';
|
|
import 'package:doctor_app_flutter/core/model/livecare/end_call_req.dart';
|
|
import 'package:doctor_app_flutter/core/model/livecare/session_status_model.dart';
|
|
import 'package:doctor_app_flutter/core/model/livecare/start_call_res.dart';
|
|
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
|
|
import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart';
|
|
import 'package:doctor_app_flutter/utils/video_channel_utils.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import '../../locator.dart';
|
|
import '../../routes.dart';
|
|
import 'NavigationService.dart';
|
|
|
|
class VideoCallService extends BaseService {
|
|
StartCallRes? startCallRes;
|
|
PatiantInformtion? patient;
|
|
LiveCarePatientServices _liveCarePatientServices =
|
|
locator<LiveCarePatientServices>();
|
|
|
|
openVideo(
|
|
StartCallRes startModel,
|
|
PatiantInformtion patientModel,
|
|
bool isRecording,
|
|
VoidCallback onCallConnected,
|
|
VoidCallback onCallDisconnected) async {
|
|
this.startCallRes = startModel;
|
|
this.patient = patientModel;
|
|
DoctorProfileModel doctorProfile =
|
|
await getDoctorProfile(isGetProfile: true);
|
|
await VideoChannel.openVideoCallScreen(
|
|
// TODO MOSA TEST
|
|
kToken: startCallRes!.openTokenID,
|
|
kSessionId: startCallRes!.openSessionID,
|
|
kApiKey: '46209962',
|
|
// kToken: "T1==cGFydG5lcl9pZD00NzI0Nzk1NCZzaWc9NGUyZjgxMjFlYTFkNzU5NjcxNDY2ZTM2ZjM3YTVhNTI2NGY0NTI2NzpzZXNzaW9uX2lkPTJfTVg0ME56STBOemsxTkg1LU1UWXlOVGN5TmpnMk5qZzNOMzQ1YUhCcGRtcDFXbVpDTDFkNE1qbDRkWFY2TTA4cmIySi1mZyZjcmVhdGVfdGltZT0xNjI1NzI2ODg5Jm5vbmNlPTAuNjc2Nzc4OTQxNjA1MTMxNSZyb2xlPXB1Ymxpc2hlciZleHBpcmVfdGltZT0xNjI4MzE4ODg4JmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9",
|
|
// kSessionId: "2_MX40NzI0Nzk1NH5-MTYyNTcyNjg2Njg3N345aHBpdmp1WmZCL1d4Mjl4dXV6M08rb2J-fg",
|
|
// kApiKey:'47247954',
|
|
vcId: patient!.vcId!,
|
|
isRecording: isRecording,
|
|
patientName: patient!.fullName ??
|
|
(patient!.firstName != null
|
|
? "${patient!.firstName} ${patient!.lastName}"
|
|
: "-"),
|
|
tokenID: await sharedPref.getString(TOKEN),
|
|
generalId: GENERAL_ID,
|
|
doctorId: doctorProfile.doctorID!,
|
|
onFailure: (String error) {
|
|
DrAppToastMsg.showErrorToast(error);
|
|
},
|
|
onCallConnected: onCallConnected,
|
|
onCallDisconnected: onCallDisconnected,
|
|
onCallEnd: () {
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
GifLoaderDialogUtils.showMyDialog(
|
|
locator<NavigationService>().navigatorKey.currentContext!);
|
|
endCall(
|
|
patient!.vcId!,
|
|
false,
|
|
).then((value) {
|
|
GifLoaderDialogUtils.hideDialog(
|
|
locator<NavigationService>().navigatorKey.currentContext!);
|
|
if (hasError) {
|
|
DrAppToastMsg.showErrorToast(error);
|
|
} else
|
|
locator<NavigationService>()
|
|
.navigateTo(PATIENTS_END_Call, arguments: {
|
|
"patient": patient,
|
|
});
|
|
});
|
|
});
|
|
},
|
|
onCallNotRespond: (SessionStatusModel sessionStatusModel) {
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
GifLoaderDialogUtils.showMyDialog(
|
|
locator<NavigationService>().navigatorKey.currentContext!);
|
|
endCall(
|
|
patient!.vcId!,
|
|
sessionStatusModel.sessionStatus == 3,
|
|
).then((value) {
|
|
GifLoaderDialogUtils.hideDialog(
|
|
locator<NavigationService>().navigatorKey.currentContext!);
|
|
if (hasError) {
|
|
DrAppToastMsg.showErrorToast(error);
|
|
} else {
|
|
locator<NavigationService>()
|
|
.navigateTo(PATIENTS_END_Call, arguments: {
|
|
"patient": patient,
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
Future endCall(int vCID, bool isPatient) async {
|
|
hasError = false;
|
|
await getDoctorProfile(isGetProfile: true);
|
|
EndCallReq endCallReq = new EndCallReq();
|
|
endCallReq.doctorId = doctorProfile!.doctorID;
|
|
endCallReq.generalid = 'Cs2020@2016\$2958';
|
|
endCallReq.vCID = vCID;
|
|
endCallReq.isDestroy = isPatient;
|
|
await _liveCarePatientServices.endCall(endCallReq);
|
|
if (_liveCarePatientServices.hasError) {
|
|
error = _liveCarePatientServices.error;
|
|
}
|
|
}
|
|
}
|