mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 23:36:42 +01:00
Must use unlimited channels to avoid blocking the OkHttp threads.
This commit is contained in:
@@ -32,6 +32,7 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.IO
|
import kotlinx.coroutines.IO
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
|
import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED
|
||||||
import kotlinx.coroutines.coroutineScope
|
import kotlinx.coroutines.coroutineScope
|
||||||
import kotlinx.coroutines.withTimeoutOrNull
|
import kotlinx.coroutines.withTimeoutOrNull
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ suspend fun INostrClient.sendAndWaitForResponse(
|
|||||||
relayList: Set<NormalizedRelayUrl>,
|
relayList: Set<NormalizedRelayUrl>,
|
||||||
timeoutInSeconds: Long = 15,
|
timeoutInSeconds: Long = 15,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val resultChannel = Channel<Result>()
|
val resultChannel = Channel<Result>(UNLIMITED)
|
||||||
|
|
||||||
Log.d("sendAndWaitForResponse", "Waiting for ${relayList.size} responses")
|
Log.d("sendAndWaitForResponse", "Waiting for ${relayList.size} responses")
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
|||||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
|
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
|
import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED
|
||||||
import kotlinx.coroutines.withTimeoutOrNull
|
import kotlinx.coroutines.withTimeoutOrNull
|
||||||
|
|
||||||
suspend fun INostrClient.downloadFirstEvent(
|
suspend fun INostrClient.downloadFirstEvent(
|
||||||
@@ -67,7 +68,7 @@ suspend fun INostrClient.downloadFirstEvent(
|
|||||||
subscriptionId: String = newSubId(),
|
subscriptionId: String = newSubId(),
|
||||||
filters: Map<NormalizedRelayUrl, List<Filter>>,
|
filters: Map<NormalizedRelayUrl, List<Filter>>,
|
||||||
): Event? {
|
): Event? {
|
||||||
val resultChannel = Channel<Event>()
|
val resultChannel = Channel<Event>(UNLIMITED)
|
||||||
|
|
||||||
val listener =
|
val listener =
|
||||||
object : IRelayClientListener {
|
object : IRelayClientListener {
|
||||||
|
|||||||
Reference in New Issue
Block a user