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
bdcff30c
Commit
bdcff30c
authored
Feb 01, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix packet resend
parent
c980bf1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
20 deletions
+19
-20
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
...moe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
+17
-18
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt
...ndroid/network/protocol/packet/chat/receive/MessageSvc.kt
+2
-2
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
View file @
bdcff30c
...
@@ -342,34 +342,33 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
...
@@ -342,34 +342,33 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
require
(
timeoutMillis
>
0
)
{
"timeoutMillis must > 0"
}
require
(
timeoutMillis
>
0
)
{
"timeoutMillis must > 0"
}
require
(
retry
>=
0
)
{
"retry must >= 0"
}
require
(
retry
>=
0
)
{
"retry must >= 0"
}
val
handler
=
PacketListener
(
commandName
=
commandName
,
sequenceId
=
sequenceId
)
packetListeners
.
addLast
(
handler
)
var
lastException
:
Exception
?
=
null
var
lastException
:
Exception
?
=
null
repeat
(
retry
+
1
)
{
repeat
(
retry
+
1
)
{
val
handler
=
PacketListener
(
commandName
=
commandName
,
sequenceId
=
sequenceId
)
packetListeners
.
addLast
(
handler
)
try
{
try
{
return
doSendAndReceive
(
timeoutMillis
,
handler
)
withContext
(
this
@QQAndroidBotNetworkHandler
.
coroutineContext
+
CoroutineName
(
"Packet sender"
))
{
channel
.
send
(
delegate
)
}
bot
.
logger
.
info
(
"Send: ${this.commandName}"
)
try
{
return
withTimeoutOrNull
(
timeoutMillis
)
{
@Suppress
(
"UNCHECKED_CAST"
)
handler
.
await
()
as
E
// 不要 `withTimeout`. timeout 的异常会不知道去哪了.
}
?:
net
.
mamoe
.
mirai
.
qqandroid
.
utils
.
inline
{
error
(
"timeout when receiving response of $commandName"
)
}
}
finally
{
packetListeners
.
remove
(
handler
)
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
lastException
=
e
lastException
=
e
}
}
}
}
packetListeners
.
remove
(
handler
)
throw
lastException
!!
throw
lastException
!!
}
}
private
suspend
inline
fun
<
E
:
Packet
>
OutgoingPacket
.
doSendAndReceive
(
timeoutMillis
:
Long
=
3000
,
handler
:
PacketListener
):
E
{
withContext
(
this
@QQAndroidBotNetworkHandler
.
coroutineContext
+
CoroutineName
(
"Packet sender"
))
{
channel
.
send
(
delegate
)
}
bot
.
logger
.
info
(
"Send: ${this.commandName}"
)
return
withTimeoutOrNull
(
timeoutMillis
)
{
@Suppress
(
"UNCHECKED_CAST"
)
handler
.
await
()
as
E
// 不要 `withTimeout`. timeout 的异常会不知道去哪了.
}
?:
net
.
mamoe
.
mirai
.
qqandroid
.
utils
.
inline
{
error
(
"timeout when receiving response of $commandName"
)
}
}
@PublishedApi
@PublishedApi
internal
val
packetListeners
=
LockFreeLinkedList
<
PacketListener
>()
internal
val
packetListeners
=
LockFreeLinkedList
<
PacketListener
>()
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt
View file @
bdcff30c
...
@@ -192,8 +192,8 @@ internal class MessageSvc {
...
@@ -192,8 +192,8 @@ internal class MessageSvc {
)
)
),
),
msgSeq
=
client
.
atomicNextMessageSequenceId
(),
msgSeq
=
client
.
atomicNextMessageSequenceId
(),
msgRand
=
Random
.
nextInt
().
absoluteValue
msgRand
=
123
,
// syncCookie = client.c2cMessageSync.syncCookie.takeIf { it.isNotEmpty() } ?: "08 92 C2 C4 F1 05 10 92 C2 C4 F1 05 18 E6 ED B9 C3 02 20 89 FE BE A4 06 28 89 84 F9 A2 06 48 DE 8C EA E5 0E 58 D9 BD BB A0 09 60 1D 68 92 C2 C4 F1 05 70 00".hexToBytes(),
syncCookie
=
client
.
c2cMessageSync
.
syncCookie
?.
takeIf
{
it
.
isNotEmpty
()
}
?:
byteArrayOf
()
// msgVia = 1
// msgVia = 1
)
)
)
)
...
...
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