changes local

dev_v3.13.6_voipcall
Aamir Muhammad 2 years ago
parent 42c0fb5ca0
commit 66a979f924

@ -291,7 +291,7 @@ class _IncomingCallState extends State<IncomingCall> with SingleTickerProviderSt
Duration(seconds: 30),
() async {
if (!isAccepted) {
callProv!.NoAnswer();
await callProv!.noAnswer();
}
},
);

@ -359,7 +359,6 @@ class PushNotificationHandler {
// Permission.audio,
// Permission.microphone,
].request();
print("=-=-=-=-=-=-=-=-=-=-");
print(statuses[Permission.location]);
}
} catch (_) {

@ -34,91 +34,6 @@ class _StartCallPageState extends State<StartCallPage> {
super.dispose();
}
// void startCall() async {
// IncomingCallModel? sessionData;
// // dynamic calls = await FlutterCallkitIncoming.activeCalls();
// // if (calls.isNotEmpty) {
// // sessionData.extra.callerDetails = {"id":341682,"userName":"Aamir.Muhammad","email":"Aamir.Muhammad@cloudsolutions.com.sa","phone":null,"title":"Aamir Saleem Ahmad Dost Muhammad","token":"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiIzNDE2ODIiLCJlbWFpbCI6IkFhbWlyLk11aGFtbWFkQGNsb3Vkc29sdXRpb25zLmNvbS5zYSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvdXNlcmRhdGEiOiJBYW1pci5NdWhhbW1hZCIsIm5iZiI6MTcwNzIwNTAyMywiZXhwIjoxNzA3MjkxNDIzLCJpYXQiOjE3MDcyMDUwMjN9.Zz2bcsMwiLAAWGZh2E_p5Qs6ItMt0JHhDFI_0DLdggCQtt6HHcT4n8nvqMZx-uYr3jLwqhA_IAjTuaCeSE15sw","isDomainUser":true,"isActiveCode":false,"encryptedUserId":"nn7RkYzbnQc=","encryptedUserName":"/QruOyp4QMcmNXKZlljUgg=="};
// // sessionData = IncomingCallModel.fromRawJson(jsonEncode(calls[0]));
// // if (kDebugMode) {
// // print(sessionData!.toRawJson());
// // }
// if (cProv!.isUserOnline) {
// AppState().isBackgroundCall = true;
// if (kDebugMode) {
// print("====== Processing Incoming Call in Online State =========");
// }
// await cProv!.startIncomingCallViaKit(inCallData: sessionData!.extra!.callerDetails!.toJson(), isVCall: sessionData.extra!.callType == "video" ? true : false);
// cProv!.init();
// isCallConnected = true;
// } else {
// AppState().isBackgroundCall = true;
// if (kDebugMode) {
// print("====== Processing Incoming Call =========");
// }
// // cProv.isUserOnline = provider.isUserOnline;
// await cProv!.startIncomingCallViaKit(inCallData: sessionData!.extra!.callerDetails!.toJson(), isVCall: sessionData!.extra!.callType == "video" ? true : false);
// try {
// AppState().setchatUserDetails = UserAutoLoginModel(response: Response.fromJson(sessionData.extra!.loginDetails!.toJson()), errorResponses: null);
// // await cProv!.buildHubConnection().whenComplete(() {
// // cProv!.init();
// // isCallConnected = true;
// // });
// } catch (e) {
// print(e);
// }
// }
// //}
//
// // cProv.startRecording();
// }
// void startIosCall() async {
// IosCallPayload iosCallPayload = widget.payload!;
// var userID = iosCallPayload.incomingCallReciverId;
// var callType = iosCallPayload.incomingCallType;
// SingleUserChatModel inCallData = SingleUserChatModel(
// targetUserName: iosCallPayload.incomingCallerName,
// chatEventId: 3,
// targetUserId: int.parse(iosCallPayload.incomingCallerId!),
// currentUserId: int.parse(userID.toString()),
// );
// if (cProv!.isUserOnline) {
// AppState().isBackgroundCall = true;
// if (kDebugMode) {
// print("====== Processing Incoming Call in Online State =========");
// }
// await cProv!.startIncomingCallViaKit(inCallData: inCallData.toJson(), isVCall: callType == "video" ? true : false);
// cProv!.init();
// isCallConnected = true;
// } else {
// if (kDebugMode) {
// print("====== Processing Incoming Call =========");
// }
// AppState().isBackgroundCall = true;
// UserAutoLoginModel userLoginResponse = await ChatService().getUserCallToken(userid: userID.toString());
// if (userLoginResponse.response != null) {
// AppState().setchatUserDetails = userLoginResponse;
// AppSharedPrefs().setStringFromPrefs("userLoginChatDetails", jsonEncode(userLoginResponse.response));
//
// await cProv!.startIncomingCallViaKit(inCallData: inCallData.toJson(), isVCall: callType == "video" ? true : false);
// try {
// AppState().setchatUserDetails = UserAutoLoginModel(response: userLoginResponse.response, errorResponses: null);
// // await cProv!.buildHubConnection().whenComplete(() {
// // cProv!.init();
// // isCallConnected = true;
// // });
// } catch (e) {
// print(e);
// }
// }
// }
// }
// void startIosCall() {
// cProv!.startCallByRTC();
// }
@override
Widget build(BuildContext context) {
return Scaffold(
@ -333,8 +248,8 @@ class _StartCallPageState extends State<StartCallPage> {
),
RawMaterialButton(
constraints: const BoxConstraints(),
onPressed: () {
prov.handleCallComplete([{}]);
onPressed: () async {
await prov.noAnswer();
},
elevation: 2.0,
fillColor: MyColors.redA3Color,

@ -890,7 +890,14 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
// // notifyListeners();
// }
NoAnswer() {
noAnswer() async {
if (!isCallConnected && !isAccepted) {
await ping("Call_NoAnswer");
} else if (!isCallConnected) {
await ping("Call_Decline");
} else if (isCallConnected || isAccepted) {
await ping("Call_Complete");
}
handleCallComplete([{}]);
}
@ -947,11 +954,11 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
}
ping(String eventName) async {
print("============ $eventName =====================");
if (chatHubConnection != null) if (chatHubConnection!.state == HubConnectionState.Connected) {
print("============ CONNECTED ==============");
print("=-=-=-=-=-=-=- $eventName =-=-=-=-=-=-=-=-=-=-");
if (chatHubConnection != null && chatHubConnection!.state == HubConnectionState.Connected) {
dynamic payload = {"UserID": int.parse(incomingCallData!.receiverID!)};
if (eventName == "Call_Complete") payload = {"from": patientID, "to": doctorID};
print("Payload ==" + payload.toString());
await chatHubConnection!.invoke(eventName, args: [payload]).onError((error, stackTrace) {}).whenComplete(() {
if (eventName == "Call_Decline" || eventName == "Call_Complete" || eventName == "Call_NoAnswer") {
if (chatHubConnection != null) {
@ -960,9 +967,9 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
}
});
} else {
print("============ ELSE RECONNECT ==============");
print("============ RECONNECT ==============");
chatHubConnection = await createHub();
chatHubConnection!.start();
await chatHubConnection!.start();
ping(eventName);
}
}
@ -1051,13 +1058,6 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
handleCallComplete(List<Object?>? params) {
print("----------handle Call Complete Received ----------");
dynamic items = params!.toList();
debuglogger.d(items);
if (isCallConnected) ping("Call_Complete");
if (!isCallConnected && !isAccepted) {
ping("Call_NoAnswer");
} else {
if (!isCallConnected) ping("Call_Decline");
}
isCallConnected = false;
isCallStarted = false;
isVideoCall = false;
@ -1180,21 +1180,3 @@ class HttpOverrideCertificateVerificationInDev extends HttpOverrides {
return super.createHttpClient(context)..badCertificateCallback = (X509Certificate cert, String host, int port) => true;
}
}
// class ChatService extends BaseService {
// Future<getUserToken.UserAutoLoginModel> getUserCallToken({required String userid}) async {
// getUserToken.UserAutoLoginModel userLoginResponse = getUserToken.UserAutoLoginModel();
// http.post(Uri.parse("${ApiConsts.chatLoginTokenUrl}externaluserlogin"), body: {
// "employeeNumber": userid,
// "password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG",
// }).then((response) {
// userLoginResponse = getUserToken.userAutoLoginModelFromJson(response.body);
// }).onError((error, stackTrace) {
// hasError = true;
// print(error);
// super.error = error.toString();
// });
//
// return userLoginResponse;
// }
// }

Loading…
Cancel
Save