Fail websocket drain if keepalive token is removed.

This commit is contained in:
Clark
2023-09-13 12:24:54 -04:00
committed by Alex Hart
parent 11e0dd18d3
commit 51e46db42d
3 changed files with 48 additions and 29 deletions

View File

@@ -43,6 +43,8 @@ object FcmFetchManager {
private val TAG = Log.tag(FcmFetchManager::class.java)
private val EXECUTOR = SerialMonoLifoExecutor(SignalExecutors.UNBOUNDED)
private val KEEP_ALIVE_TOKEN = "FcmFetch"
val WEBSOCKET_DRAIN_TIMEOUT = 5.minutes.inWholeMilliseconds
@Volatile
@@ -140,7 +142,7 @@ object FcmFetchManager {
@JvmStatic
fun retrieveMessages(context: Context): Boolean {
val success = WebSocketDrainer.blockUntilDrainedAndProcessed(WEBSOCKET_DRAIN_TIMEOUT)
val success = WebSocketDrainer.blockUntilDrainedAndProcessed(WEBSOCKET_DRAIN_TIMEOUT, KEEP_ALIVE_TOKEN)
if (success) {
Log.i(TAG, "Successfully retrieved messages.")