@ -890,7 +890,14 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
/ / / / notifyListeners ( ) ;
/ / / / 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 ( [ { } ] ) ;
handleCallComplete ( [ { } ] ) ;
}
}
@ -947,11 +954,11 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
}
}
ping ( String eventName ) async {
ping ( String eventName ) async {
print ( " ============ $ eventName ===================== " ) ;
print ( " =-=-=-=-=-=-=- $ eventName =-=-=-=-=-=-=-=-=-=- " ) ;
if ( chatHubConnection ! = null ) if ( chatHubConnection ! . state = = HubConnectionState . Connected ) {
if ( chatHubConnection ! = null & & chatHubConnection ! . state = = HubConnectionState . Connected ) {
print ( " ============ CONNECTED ============== " ) ;
dynamic payload = { " UserID " : int . parse ( incomingCallData ! . receiverID ! ) } ;
dynamic payload = { " UserID " : int . parse ( incomingCallData ! . receiverID ! ) } ;
if ( eventName = = " Call_Complete " ) payload = { " from " : patientID , " to " : doctorID } ;
if ( eventName = = " Call_Complete " ) payload = { " from " : patientID , " to " : doctorID } ;
print ( " Payload == " + payload . toString ( ) ) ;
await chatHubConnection ! . invoke ( eventName , args: [ payload ] ) . onError ( ( error , stackTrace ) { } ) . whenComplete ( ( ) {
await chatHubConnection ! . invoke ( eventName , args: [ payload ] ) . onError ( ( error , stackTrace ) { } ) . whenComplete ( ( ) {
if ( eventName = = " Call_Decline " | | eventName = = " Call_Complete " | | eventName = = " Call_NoAnswer " ) {
if ( eventName = = " Call_Decline " | | eventName = = " Call_Complete " | | eventName = = " Call_NoAnswer " ) {
if ( chatHubConnection ! = null ) {
if ( chatHubConnection ! = null ) {
@ -960,9 +967,9 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
}
}
} ) ;
} ) ;
} else {
} else {
print ( " ============ ELSE RECONNECT ==============" ) ;
print ( " ============ RECONNECT ==============" ) ;
chatHubConnection = await createHub ( ) ;
chatHubConnection = await createHub ( ) ;
chatHubConnection ! . start ( ) ;
await chatHubConnection ! . start ( ) ;
ping ( eventName ) ;
ping ( eventName ) ;
}
}
}
}
@ -1051,13 +1058,6 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
handleCallComplete ( List < Object ? > ? params ) {
handleCallComplete ( List < Object ? > ? params ) {
print ( " ----------handle Call Complete Received ---------- " ) ;
print ( " ----------handle Call Complete Received ---------- " ) ;
dynamic items = params ! . toList ( ) ;
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 ;
isCallConnected = false ;
isCallStarted = false ;
isCallStarted = false ;
isVideoCall = false ;
isVideoCall = false ;
@ -1180,21 +1180,3 @@ class HttpOverrideCertificateVerificationInDev extends HttpOverrides {
return super . createHttpClient ( context ) . . badCertificateCallback = ( X509Certificate cert , String host , int port ) = > true ;
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 ;
/ / }
/ / }