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
ce7c9f8c
Commit
ce7c9f8c
authored
Feb 03, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove getQQOrAdd
parent
a113f0ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
+27
-10
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
...mmonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
+0
-4
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
...moe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
+27
-6
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
View file @
ce7c9f8c
...
...
@@ -37,10 +37,6 @@ internal abstract class QQAndroidBotBase constructor(
return
qqs
.
delegate
.
filteringGetOrAdd
({
it
.
id
==
id
},
{
QQImpl
(
this
as
QQAndroidBot
,
coroutineContext
,
id
)
})
}
fun
getQQOrAdd
(
id
:
Long
):
QQ
{
return
qqs
.
delegate
.
filteringGetOrAdd
({
it
.
id
==
id
},
{
QQImpl
(
this
as
QQAndroidBot
,
coroutineContext
,
id
)
})
}
override
fun
QQ
(
id
:
Long
):
QQ
{
return
QQImpl
(
this
as
QQAndroidBot
,
coroutineContext
,
id
)
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
View file @
ce7c9f8c
...
...
@@ -115,7 +115,8 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
//val msg = MessageSvc.PbGetMsg(bot.client, MsgSvc.SyncFlag.START, currentTimeSeconds).sendAndExpect<MessageSvc.PbGetMsg.Response>()
//println(msg.contentToString())
bot
.
qqs
.
delegate
.
clear
()
bot
.
groups
.
delegate
.
clear
()
val
startTime
=
currentTimeMillis
try
{
...
...
@@ -472,12 +473,12 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
/**
* 发送一个包, 并挂起直到接收到指定的返回包或超时(3000ms)
*/
suspend
fun
<
E
:
Packet
>
OutgoingPacket
.
sendAndExpect
(
timeoutMillis
:
Long
=
3000
,
retry
:
Int
=
1
):
E
{
suspend
fun
<
E
:
Packet
>
OutgoingPacket
.
sendAndExpect
(
timeoutMillis
:
Long
=
3000
,
retry
:
Int
=
0
):
E
{
require
(
timeoutMillis
>
0
)
{
"timeoutMillis must > 0"
}
require
(
retry
>=
0
)
{
"retry must >= 0"
}
var
lastException
:
Exception
?
=
null
repeat
(
retry
+
1
)
{
if
(
retry
==
0
)
{
val
handler
=
PacketListener
(
commandName
=
commandName
,
sequenceId
=
sequenceId
)
packetListeners
.
addLast
(
handler
)
try
{
...
...
@@ -492,13 +493,33 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
}
?:
net
.
mamoe
.
mirai
.
qqandroid
.
utils
.
inline
{
error
(
"timeout when receiving response of $commandName"
)
}
}
catch
(
e
:
Exception
)
{
lastException
=
e
}
finally
{
packetListeners
.
remove
(
handler
)
}
}
else
this
.
delegate
.
useBytes
{
data
,
length
->
repeat
(
retry
+
1
)
{
val
handler
=
PacketListener
(
commandName
=
commandName
,
sequenceId
=
sequenceId
)
packetListeners
.
addLast
(
handler
)
try
{
withContext
(
this
@QQAndroidBotNetworkHandler
.
coroutineContext
+
CoroutineName
(
"Packet sender"
))
{
channel
.
send
(
data
,
0
,
length
)
}
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"
)
}
}
catch
(
e
:
Exception
)
{
lastException
=
e
}
finally
{
packetListeners
.
remove
(
handler
)
}
}
throw
lastException
!!
}
throw
lastException
!!
}
@PublishedApi
...
...
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