diff --git a/aws-predictions/src/main/java/com/amplifyframework/predictions/aws/http/LivenessWebSocket.kt b/aws-predictions/src/main/java/com/amplifyframework/predictions/aws/http/LivenessWebSocket.kt index e4a34d29a7..d676621d6b 100644 --- a/aws-predictions/src/main/java/com/amplifyframework/predictions/aws/http/LivenessWebSocket.kt +++ b/aws-predictions/src/main/java/com/amplifyframework/predictions/aws/http/LivenessWebSocket.kt @@ -481,9 +481,9 @@ internal class LivenessWebSocket( } } - fun destroy() { - // Close gracefully - webSocket?.close(NORMAL_SOCKET_CLOSURE_STATUS_CODE, null) + fun destroy(reasonCode: Int = NORMAL_SOCKET_CLOSURE_STATUS_CODE) { + // Close with provided reason code + webSocket?.close(reasonCode, null) } fun adjustedDate(date: Long = Date().time): Long { diff --git a/aws-predictions/src/main/java/com/amplifyframework/predictions/aws/service/RunFaceLivenessSession.kt b/aws-predictions/src/main/java/com/amplifyframework/predictions/aws/service/RunFaceLivenessSession.kt index 0028e46359..d6d1000fdd 100644 --- a/aws-predictions/src/main/java/com/amplifyframework/predictions/aws/service/RunFaceLivenessSession.kt +++ b/aws-predictions/src/main/java/com/amplifyframework/predictions/aws/service/RunFaceLivenessSession.kt @@ -179,8 +179,8 @@ internal class RunFaceLivenessSession( } } - private fun stopLivenessSession() { + private fun stopLivenessSession(reasonCode: Int?) { livenessWebSocket.clientStoppedSession = true - livenessWebSocket.destroy() + reasonCode?.let { livenessWebSocket.destroy(it) } ?: livenessWebSocket.destroy() } } diff --git a/core/src/main/java/com/amplifyframework/predictions/models/FaceLivenessSession.kt b/core/src/main/java/com/amplifyframework/predictions/models/FaceLivenessSession.kt index 10e6e62f59..bd5d5dd6f3 100644 --- a/core/src/main/java/com/amplifyframework/predictions/models/FaceLivenessSession.kt +++ b/core/src/main/java/com/amplifyframework/predictions/models/FaceLivenessSession.kt @@ -16,14 +16,13 @@ package com.amplifyframework.predictions.models import com.amplifyframework.annotations.InternalAmplifyApi -import com.amplifyframework.core.Action @InternalAmplifyApi class FaceLivenessSession( val challenges: List, private val onVideoEvent: (VideoEvent) -> Unit, private val onChallengeResponseEvent: (ChallengeResponseEvent) -> Unit, - private val stopLivenessSession: Action + private val stopLivenessSession: (Int?) -> Unit ) { fun sendVideoEvent(videoEvent: VideoEvent) { @@ -34,7 +33,8 @@ class FaceLivenessSession( onChallengeResponseEvent(challengeResponseEvent) } - fun stopSession() { - stopLivenessSession.call() + @JvmOverloads + fun stopSession(reasonCode: Int? = null) { + stopLivenessSession(reasonCode) } }