Skip to content

Commit

Permalink
Add collect parcels logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sdsantos committed Sep 7, 2023
1 parent 710b0c4 commit 57b8f90
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ internal constructor(
}

try {
logger.log(Level.INFO, "ReceiveMessages receive")
receiveMessages
.receive()
.collect(incomingMessageChannel::emit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import tech.relaycorp.awaladroid.Awala
import tech.relaycorp.awaladroid.common.Logging.logger
import java.util.logging.Level

internal class IncomingParcelBroadcastReceiver : BroadcastReceiver() {

internal var coroutineContext: CoroutineContext = Dispatchers.IO

override fun onReceive(context: Context?, intent: Intent?) {
logger.log(Level.INFO, "IncomingParcelBroadcastReceiver onReceive")
CoroutineScope(coroutineContext).launch {
Awala.getContextOrThrow().gatewayClient.checkForNewMessages()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tech.relaycorp.awaladroid.messaging

import java.util.logging.Level
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.flatMapLatest
Expand All @@ -26,6 +25,7 @@ import tech.relaycorp.relaynet.ramf.InvalidPayloadException
import tech.relaycorp.relaynet.ramf.RAMFException
import tech.relaycorp.relaynet.wrappers.cms.EnvelopedDataException
import tech.relaycorp.relaynet.wrappers.nodeId
import java.util.logging.Level

internal class ReceiveMessages(
private val pdcClientBuilder: () -> PDCClient = { PoWebClient.initLocal(Awala.POWEB_PORT) }
Expand All @@ -41,8 +41,10 @@ internal class ReceiveMessages(
.flatMapLatest { nonceSigners ->
val pdcClient = pdcClientBuilder()
try {
logger.log(Level.INFO, "collectParcels")
collectParcels(pdcClient, nonceSigners)
.onCompletion {
logger.log(Level.INFO, "collectParcels onCompletion")
@Suppress("BlockingMethodInNonBlockingContext")
pdcClient.close()
}
Expand Down Expand Up @@ -82,6 +84,7 @@ internal class ReceiveMessages(
pdcClient
.collectParcels(nonceSigners, StreamingMode.CloseUponCompletion)
.mapNotNull { parcelCollection ->
logger.log(Level.INFO, "Got a parcel: $parcelCollection")
val parcel = try {
parcelCollection.deserializeAndValidateParcel()
} catch (exp: RAMFException) {
Expand Down

0 comments on commit 57b8f90

Please sign in to comment.