Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
0dfea069
Commit
0dfea069
authored
Apr 11, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sequence cache to filter duplicated events, fix #221
parent
16d6c562
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
13 deletions
+23
-13
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt
...tlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt
+1
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt
...ndroid/network/protocol/packet/chat/receive/OnlinePush.kt
+22
-13
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt
View file @
0dfea069
...
...
@@ -131,6 +131,7 @@ internal open class QQAndroidClient(
internal
fun
nextHighwayDataTransSequenceIdForApplyUp
():
Int
=
highwayDataTransSequenceIdForApplyUp
.
getAndAdd
(
2
)
internal
val
onlinePushCacheList
:
LockFreeLinkedList
<
Short
>
=
LockFreeLinkedList
()
internal
val
pbPushTransMsgCacheList
:
LockFreeLinkedList
<
Int
>
=
LockFreeLinkedList
()
val
appClientVersion
:
Int
=
0
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt
View file @
0dfea069
...
...
@@ -123,6 +123,14 @@ internal class OnlinePush {
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
,
sequenceId
:
Int
):
Packet
?
{
val
content
=
this
.
readProtoBuf
(
OnlinePushTrans
.
PbMsgInfo
.
serializer
())
val
cache
=
bot
.
client
.
pbPushTransMsgCacheList
.
removeUntilFirst
{
it
==
content
.
msgSeq
}
if
(
cache
==
null
)
{
bot
.
client
.
pbPushTransMsgCacheList
.
addLast
(
content
.
msgSeq
)
}
else
{
bot
.
client
.
pbPushTransMsgCacheList
.
remove
(
cache
)
return
null
}
content
.
msgData
.
read
<
Unit
>
{
when
(
content
.
msgType
)
{
44
->
{
...
...
@@ -237,17 +245,6 @@ internal class OnlinePush {
}.
flatMap
{
it
.
vMsg
.
read
{
mapper
(
it
)
}
}
}
private
inline
fun
LockFreeLinkedList
<
Short
>.
removeUntilFirst
(
block
:
(
Short
)
->
Boolean
):
Short
?
{
this
.
forEach
{
if
(!
block
(
it
))
{
this
.
remove
(
it
)
}
else
{
return
it
}
}
return
null
}
private
fun
lambda732
(
block
:
ByteReadPacket
.(
group
:
GroupImpl
,
bot
:
QQAndroidBot
)
->
Sequence
<
Packet
>):
ByteReadPacket
.(
group
:
GroupImpl
,
bot
:
QQAndroidBot
)
->
Sequence
<
Packet
>
{
return
block
...
...
@@ -514,7 +511,7 @@ internal class OnlinePush {
?.
let
{
processor
->
processor
(
notifyMsgBody
,
bot
)
}
?:
kotlin
.
run
{
bot
.
network
.
logger
.
debug
{
"unknown group 528 type
${notifyMsgBody.uSubMsgType
}, data: "
+
notifyMsgBody
.
vProtobuf
.
toUHexString
()
"unknown group 528 type
0x${notifyMsgBody.uSubMsgType.toUHexString("")
}, data: "
+
notifyMsgBody
.
vProtobuf
.
toUHexString
()
}
return
@
deco
emptySequence
()
}
...
...
@@ -573,3 +570,15 @@ internal class OnlinePush {
}
}
}
private
inline
fun
<
E
>
LockFreeLinkedList
<
E
>.
removeUntilFirst
(
block
:
(
E
)
->
Boolean
):
E
?
{
this
.
forEach
{
if
(!
block
(
it
))
{
this
.
remove
(
it
)
}
else
{
return
it
}
}
return
null
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment