Commit 4a217d83 authored by Him188's avatar Him188

Fix #247

parent 6f694972
......@@ -155,6 +155,20 @@ internal open class QQAndroidClient(
private val messageSequenceId: AtomicInt = atomic(22911)
internal fun atomicNextMessageSequenceId(): Int = messageSequenceId.getAndAdd(2)
private val friendSeq: AtomicInt = atomic(22911)
internal fun getFriendSeq(): Int {
return friendSeq.value
}
internal fun nextFriendSeq(): Int {
return friendSeq.incrementAndGet()
}
internal fun setFriendSeq(compare: Int, id: Int): Boolean {
return friendSeq.compareAndSet(compare, id % 65535)
}
private val requestPacketRequestId: AtomicInt = atomic(1921334513)
internal fun nextRequestPacketRequestId(): Int = requestPacketRequestId.getAndAdd(2)
......
......@@ -229,10 +229,21 @@ internal class MessageSvc {
}
}
166 -> {
if (msg.msgHead.fromUin == bot.id) {
loop@ while (true) {
val instance = bot.client.getFriendSeq()
if (instance < msg.msgHead.msgSeq) {
if (bot.client.setFriendSeq(instance, msg.msgHead.msgSeq)) {
break@loop
}
} else break@loop
}
return@mapNotNull null
}
val friend = bot.getFriendOrNull(msg.msgHead.fromUin) ?: return@mapNotNull null
friend.checkIsFriendImpl()
if (msg.msgHead.fromUin == bot.id || !bot.firstLoginSucceed) {
if (!bot.firstLoginSucceed) {
return@mapNotNull null
}
......@@ -376,7 +387,7 @@ internal class MessageSvc {
sender = client.bot,
target = qq,
time = currentTimeSeconds.toInt(),
sequenceId = rand,
sequenceId = client.nextFriendSeq(),
originalMessage = message
)
sourceCallback(source)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment