Skip to content
Snippets Groups Projects
Verified Commit 8a638126 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

fix: correct issue with backlog loading

parent e15af5af
No related branches found
No related tags found
No related merge requests found
......@@ -15,4 +15,4 @@ plugins {
}
group = "de.justjanne.libquassel"
version = "0.9.0"
version = "0.9.1"
......@@ -135,6 +135,29 @@ class ClientBacklogManager(
super.receiveBacklogFiltered(bufferId, first, last, limit, additional, type, flags, messages)
}
override fun receiveBacklogForward(
bufferId: BufferId,
first: MsgId,
last: MsgId,
limit: Int,
type: Int,
flags: Int,
messages: QVariantList
) {
bufferForwardQueue.resume(
BacklogData.BufferForward(
bufferId,
first,
last,
limit,
MessageType.of(type.toUInt()),
MessageFlag.of(flags.toUInt())
),
messages
)
super.receiveBacklogForward(bufferId, first, last, limit, type, flags, messages)
}
override fun receiveBacklogAll(first: MsgId, last: MsgId, limit: Int, additional: Int, messages: QVariantList) {
allQueue.resume(
BacklogData.All(
......
......@@ -9,6 +9,7 @@
package de.justjanne.libquassel.client.util
import org.slf4j.LoggerFactory
import kotlin.coroutines.Continuation
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
......@@ -22,7 +23,11 @@ class CoroutineKeyedQueue<Key, Value> {
}
fun resume(key: Key, value: Value) {
val continuations = waiting[key].orEmpty().distinct()
val queue = waiting[key]
if (queue == null) {
logger.warn("Trying to resume message with unknown key: $key")
}
val continuations = queue.orEmpty().distinct()
for (continuation in continuations) {
continuation.resume(value)
}
......@@ -30,4 +35,8 @@ class CoroutineKeyedQueue<Key, Value> {
waiting[it]?.removeAll(continuations)
}
}
companion object {
private val logger = LoggerFactory.getLogger(CoroutineKeyedQueue::class.java)
}
}
......@@ -18,16 +18,21 @@ import de.justjanne.libquassel.protocol.connection.ProtocolVersion
import de.justjanne.libquassel.protocol.exceptions.HandshakeException
import de.justjanne.libquassel.protocol.features.FeatureSet
import de.justjanne.libquassel.protocol.io.CoroutineChannel
import de.justjanne.libquassel.protocol.models.ids.BufferId
import de.justjanne.libquassel.protocol.models.ids.MsgId
import de.justjanne.libquassel.protocol.session.CoreState
import de.justjanne.testcontainersci.api.providedContainer
import de.justjanne.testcontainersci.extension.CiContainers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import java.net.InetSocketAddress
import java.time.Duration
import javax.net.ssl.SSLContext
import kotlin.test.assertEquals
@ExperimentalCoroutinesApi
@CiContainers
......@@ -36,8 +41,8 @@ class ClientTest {
QuasselCoreContainer()
}
private val username = "kuschku"
private val password = "goalielecturetrawl"
private val username = "AzureDiamond"
private val password = "hunter2"
@Test
fun testConnect(): Unit = runBlocking {
......@@ -91,6 +96,20 @@ class ClientTest {
}
session.handshakeHandler.login(username, password)
session.baseInitHandler.waitForInitDone()
withTimeout(Duration.ofSeconds(5).toMillis()) {
assertEquals(
emptyList(),
session.backlogManager.backlog(bufferId = BufferId(1), limit = 5)
)
assertEquals(
emptyList(),
session.backlogManager.backlogAll(limit = 5)
)
assertEquals(
emptyList(),
session.backlogManager.backlogForward(bufferId = BufferId(1), limit = 5)
)
}
channel.close()
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment