|
|
|
|
@ -29,7 +29,6 @@ class ChatVoipCall {
|
|
|
|
|
ChatVoipCall._internal();
|
|
|
|
|
|
|
|
|
|
factory ChatVoipCall() => _instance;
|
|
|
|
|
|
|
|
|
|
late ChatProviderModel prov;
|
|
|
|
|
late ChatCallProvider cProv;
|
|
|
|
|
dynamic inCallData;
|
|
|
|
|
@ -72,13 +71,7 @@ class ChatVoipCall {
|
|
|
|
|
textDecline: 'Decline',
|
|
|
|
|
textMissedCall: 'Missed call',
|
|
|
|
|
textCallback: 'Call back',
|
|
|
|
|
extra: {
|
|
|
|
|
"loginDetails": autoLoginData.toJson(),
|
|
|
|
|
"callerDetails": callerData.toJson(),
|
|
|
|
|
'isIncomingCall': true,
|
|
|
|
|
'isUserOnline': isUserOnline,
|
|
|
|
|
'callType' : data!.data["callType"]
|
|
|
|
|
},
|
|
|
|
|
extra: {"loginDetails": autoLoginData.toJson(), "callerDetails": callerData.toJson(), 'isIncomingCall': true, 'isUserOnline': isUserOnline, 'callType': data!.data["callType"]},
|
|
|
|
|
android: const AndroidParams(
|
|
|
|
|
isCustomNotification: true,
|
|
|
|
|
isShowLogo: false,
|
|
|
|
|
@ -179,9 +172,11 @@ class ChatVoipCall {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> declineCall() async {
|
|
|
|
|
if (isUserOnline && chatHubConnection != null) {
|
|
|
|
|
if (isUserOnline) {
|
|
|
|
|
HubConnection hc = await makeHub();
|
|
|
|
|
await hc.start();
|
|
|
|
|
print("Connection State ===" + chatHubConnection.state.toString());
|
|
|
|
|
if (chatHubConnection.state == HubConnectionState.Connected) {
|
|
|
|
|
if (hc.state == HubConnectionState.Connected) {
|
|
|
|
|
if (sessionData?.extra != null) {
|
|
|
|
|
chatHubConnection.invoke("HangUpAsync", args: [
|
|
|
|
|
int.parse(sessionData.extra!.callerDetails!.currentUserId.toString()),
|
|
|
|
|
@ -191,15 +186,12 @@ class ChatVoipCall {
|
|
|
|
|
int.parse(sessionData.extra!.callerDetails!.currentUserId.toString()),
|
|
|
|
|
1,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
FlutterCallkitIncoming.endCall(sessionData.id!);
|
|
|
|
|
chatHubConnection = hc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true);
|
|
|
|
|
HubConnection hc = HubConnectionBuilder()
|
|
|
|
|
.withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${sessionData.extra!.loginDetails!.id}&source=Desktop&access_token=${sessionData.extra?.loginDetails!.token}", options: httpOp)
|
|
|
|
|
.withAutomaticReconnect(retryDelays: <int>[2000, 5000, 10000, 20000]).build();
|
|
|
|
|
HubConnection hc = await makeHub();
|
|
|
|
|
await hc.start();
|
|
|
|
|
await hc.invoke(
|
|
|
|
|
"HangUpAsync",
|
|
|
|
|
@ -216,4 +208,12 @@ class ChatVoipCall {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<HubConnection> makeHub() async {
|
|
|
|
|
HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true);
|
|
|
|
|
HubConnection hc = HubConnectionBuilder()
|
|
|
|
|
.withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${sessionData.extra!.loginDetails!.id}&source=Desktop&access_token=${sessionData.extra?.loginDetails!.token}", options: httpOp)
|
|
|
|
|
.withAutomaticReconnect(retryDelays: <int>[2000, 5000, 10000, 20000]).build();
|
|
|
|
|
return hc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|