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
7de04824
Commit
7de04824
authored
Feb 19, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix null packet
parent
c32843fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
...moe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
+5
-5
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt
.../mirai/qqandroid/network/protocol/packet/PacketFactory.kt
+5
-5
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
View file @
7de04824
...
@@ -373,7 +373,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
...
@@ -373,7 +373,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
}
}
// with generic type, less mistakes
// with generic type, less mistakes
private
suspend
inline
fun
<
P
:
Packet
>
generifiedParsePacket
(
input
:
Input
)
{
private
suspend
fun
<
P
:
Packet
?
>
generifiedParsePacket
(
input
:
Input
)
{
KnownPacketFactories
.
parseIncomingPacket
(
bot
,
input
)
{
packetFactory
:
PacketFactory
<
P
>,
packet
:
P
,
commandName
:
String
,
sequenceId
:
Int
->
KnownPacketFactories
.
parseIncomingPacket
(
bot
,
input
)
{
packetFactory
:
PacketFactory
<
P
>,
packet
:
P
,
commandName
:
String
,
sequenceId
:
Int
->
handlePacket
(
packetFactory
,
packet
,
commandName
,
sequenceId
)
handlePacket
(
packetFactory
,
packet
,
commandName
,
sequenceId
)
if
(
packet
is
MultiPacket
<
*
>)
{
if
(
packet
is
MultiPacket
<
*
>)
{
...
@@ -387,7 +387,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
...
@@ -387,7 +387,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
/**
/**
* 处理解析完成的包.
* 处理解析完成的包.
*/
*/
suspend
fun
<
P
:
Packet
>
handlePacket
(
packetFactory
:
PacketFactory
<
P
>?,
packet
:
P
,
commandName
:
String
,
sequenceId
:
Int
)
{
suspend
fun
<
P
:
Packet
?
>
handlePacket
(
packetFactory
:
PacketFactory
<
P
>?,
packet
:
P
,
commandName
:
String
,
sequenceId
:
Int
)
{
// highest priority: pass to listeners (attached by sendAndExpect).
// highest priority: pass to listeners (attached by sendAndExpect).
packetListeners
.
forEach
{
listener
->
packetListeners
.
forEach
{
listener
->
if
(
listener
.
filter
(
commandName
,
sequenceId
)
&&
packetListeners
.
remove
(
listener
))
{
if
(
listener
.
filter
(
commandName
,
sequenceId
)
&&
packetListeners
.
remove
(
listener
))
{
...
@@ -396,7 +396,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
...
@@ -396,7 +396,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
}
}
// check top-level cancelling
// check top-level cancelling
if
(
PacketReceivedEvent
(
packet
).
broadcast
().
isCancelled
)
{
if
(
packet
!=
null
&&
PacketReceivedEvent
(
packet
).
broadcast
().
isCancelled
)
{
return
return
}
}
...
@@ -412,7 +412,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
...
@@ -412,7 +412,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
if
(
packet
is
CancellableEvent
&&
packet
.
isCancelled
)
return
if
(
packet
is
CancellableEvent
&&
packet
.
isCancelled
)
return
}
}
if
(
bot
.
logger
.
isEnabled
||
logger
.
isEnabled
)
{
if
(
packet
!=
null
&&
bot
.
logger
.
isEnabled
||
logger
.
isEnabled
)
{
val
logMessage
=
"Received: ${packet.toString().replace("
\
n
", """
\
n
""").replace("
\
r
", "")}"
val
logMessage
=
"Received: ${packet.toString().replace("
\
n
", """
\
n
""").replace("
\
r
", "")}"
if
(
packet
is
Event
)
{
if
(
packet
is
Event
)
{
...
@@ -585,7 +585,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
...
@@ -585,7 +585,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
internal
inner
class
PacketListener
(
// callback
internal
inner
class
PacketListener
(
// callback
val
commandName
:
String
,
val
commandName
:
String
,
val
sequenceId
:
Int
val
sequenceId
:
Int
)
:
CompletableDeferred
<
Packet
>
by
CompletableDeferred
(
supervisor
)
{
)
:
CompletableDeferred
<
Packet
?
>
by
CompletableDeferred
(
supervisor
)
{
fun
filter
(
commandName
:
String
,
sequenceId
:
Int
)
=
this
.
commandName
==
commandName
&&
this
.
sequenceId
==
sequenceId
fun
filter
(
commandName
:
String
,
sequenceId
:
Int
)
=
this
.
commandName
==
commandName
&&
this
.
sequenceId
==
sequenceId
}
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt
View file @
7de04824
...
@@ -97,10 +97,10 @@ internal abstract class IncomingPacketFactory<TPacket : Packet?>(
...
@@ -97,10 +97,10 @@ internal abstract class IncomingPacketFactory<TPacket : Packet?>(
}
}
@JvmName
(
"decode0"
)
@JvmName
(
"decode0"
)
private
suspend
inline
fun
<
P
:
Packet
>
OutgoingPacketFactory
<
P
>.
decode
(
bot
:
QQAndroidBot
,
packet
:
ByteReadPacket
):
P
=
packet
.
decode
(
bot
)
private
suspend
inline
fun
<
P
:
Packet
?
>
OutgoingPacketFactory
<
P
>.
decode
(
bot
:
QQAndroidBot
,
packet
:
ByteReadPacket
):
P
=
packet
.
decode
(
bot
)
@JvmName
(
"decode1"
)
@JvmName
(
"decode1"
)
private
suspend
inline
fun
<
P
:
Packet
>
IncomingPacketFactory
<
P
>.
decode
(
bot
:
QQAndroidBot
,
packet
:
ByteReadPacket
,
sequenceId
:
Int
):
P
=
private
suspend
inline
fun
<
P
:
Packet
?
>
IncomingPacketFactory
<
P
>.
decode
(
bot
:
QQAndroidBot
,
packet
:
ByteReadPacket
,
sequenceId
:
Int
):
P
=
packet
.
decode
(
bot
,
sequenceId
)
packet
.
decode
(
bot
,
sequenceId
)
internal
val
DECRYPTER_16_ZERO
=
ByteArray
(
16
)
internal
val
DECRYPTER_16_ZERO
=
ByteArray
(
16
)
...
@@ -169,7 +169,7 @@ internal object KnownPacketFactories {
...
@@ -169,7 +169,7 @@ internal object KnownPacketFactories {
// do not inline. Exceptions thrown will not be reported correctly
// do not inline. Exceptions thrown will not be reported correctly
@UseExperimental
(
MiraiInternalAPI
::
class
)
@UseExperimental
(
MiraiInternalAPI
::
class
)
@Suppress
(
"UNCHECKED_CAST"
)
@Suppress
(
"UNCHECKED_CAST"
)
suspend
fun
<
T
:
Packet
>
parseIncomingPacket
(
bot
:
QQAndroidBot
,
rawInput
:
Input
,
consumer
:
PacketConsumer
<
T
>)
=
with
(
rawInput
)
{
suspend
fun
<
T
:
Packet
?
>
parseIncomingPacket
(
bot
:
QQAndroidBot
,
rawInput
:
Input
,
consumer
:
PacketConsumer
<
T
>)
=
with
(
rawInput
)
{
// login
// login
val
flag1
=
readInt
()
val
flag1
=
readInt
()
...
@@ -229,7 +229,7 @@ internal object KnownPacketFactories {
...
@@ -229,7 +229,7 @@ internal object KnownPacketFactories {
}
}
@UseExperimental
(
MiraiInternalAPI
::
class
)
@UseExperimental
(
MiraiInternalAPI
::
class
)
internal
suspend
fun
<
T
:
Packet
>
handleIncomingPacket
(
it
:
IncomingPacket
<
T
>,
bot
:
QQAndroidBot
,
flag2
:
Int
,
consumer
:
PacketConsumer
<
T
>)
{
internal
suspend
fun
<
T
:
Packet
?
>
handleIncomingPacket
(
it
:
IncomingPacket
<
T
>,
bot
:
QQAndroidBot
,
flag2
:
Int
,
consumer
:
PacketConsumer
<
T
>)
{
if
(
it
.
packetFactory
==
null
)
{
if
(
it
.
packetFactory
==
null
)
{
bot
.
network
.
logger
.
debug
(
"Received commandName: ${it.commandName}"
)
bot
.
network
.
logger
.
debug
(
"Received commandName: ${it.commandName}"
)
PacketLogger
.
warning
{
"找不到 PacketFactory"
}
PacketLogger
.
warning
{
"找不到 PacketFactory"
}
...
@@ -337,7 +337,7 @@ internal object KnownPacketFactories {
...
@@ -337,7 +337,7 @@ internal object KnownPacketFactories {
return
IncomingPacket
(
packetFactory
,
ssoSequenceId
,
packet
,
commandName
)
return
IncomingPacket
(
packetFactory
,
ssoSequenceId
,
packet
,
commandName
)
}
}
private
suspend
fun
<
T
:
Packet
>
ByteReadPacket
.
parseOicqResponse
(
private
suspend
fun
<
T
:
Packet
?
>
ByteReadPacket
.
parseOicqResponse
(
bot
:
QQAndroidBot
,
bot
:
QQAndroidBot
,
packetFactory
:
OutgoingPacketFactory
<
T
>,
packetFactory
:
OutgoingPacketFactory
<
T
>,
ssoSequenceId
:
Int
,
ssoSequenceId
:
Int
,
...
...
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