Add sequenceId to MessageSource

This commit is contained in:
Him188 2020-02-21 16:29:39 +08:00
parent 776e591556
commit ff8e6e8b80
2 changed files with 7 additions and 0 deletions

View File

@ -22,6 +22,7 @@ internal inline class MessageSourceFromServer(
val delegate: ImMsgBody.SourceMsg
) : MessageSource {
override val time: Long get() = delegate.time.toLong() and 0xFFFFFFFF
override val sequenceId: Int get() = delegate.origSeqs?.firstOrNull() ?: error("cannot find sequenceId from ImMsgBody.SourceMsg")
override val messageUid: Long get() = delegate.pbReserve.loadAs(SourceMsg.ResvAttr.serializer()).origUids!!
override val sourceMessage: MessageChain get() = delegate.toMessageChain()
override val senderId: Long get() = delegate.senderUin
@ -34,6 +35,7 @@ internal inline class MessageSourceFromMsg(
val delegate: MsgComm.Msg
) : MessageSource {
override val time: Long get() = delegate.msgHead.msgTime.toLong() and 0xFFFFFFFF
override val sequenceId: Int get() = delegate.msgHead.msgSeq
override val messageUid: Long get() = delegate.msgBody.richText.attr!!.random.toLong()
override val sourceMessage: MessageChain get() = delegate.toMessageChain()
override val senderId: Long get() = delegate.msgHead.fromUin

View File

@ -26,6 +26,11 @@ import kotlin.jvm.JvmName
interface MessageSource : Message {
companion object Key : Message.Key<MessageSource>
/**
* 序列号
*/
val sequenceId: Int
/**
* 实际上是个随机数, 但服务器确实是用它当做 uid
*/