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
770865ca
Commit
770865ca
authored
Dec 06, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make close not suspend
parent
785ddd73
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/BotNetworkHandler.kt
...nMain/kotlin/net.mamoe.mirai/network/BotNetworkHandler.kt
+3
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt
....mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt
+1
-3
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/BotNetworkHandler.kt
View file @
770865ca
...
...
@@ -11,6 +11,7 @@ import net.mamoe.mirai.network.protocol.tim.packet.Packet
import
net.mamoe.mirai.network.protocol.tim.packet.login.HeartbeatPacket
import
net.mamoe.mirai.network.protocol.tim.packet.login.LoginResult
import
net.mamoe.mirai.network.protocol.tim.packet.login.RequestSKeyPacket
import
net.mamoe.mirai.utils.MiraiInternalAPI
import
net.mamoe.mirai.utils.io.PlatformDatagramChannel
/**
...
...
@@ -52,6 +53,7 @@ interface BotNetworkHandler<Socket : DataPacketSocketAdapter> : CoroutineScope {
* @see [BotSession.sendAndExpectAsync] 发送并期待一个包
* @see [TemporaryPacketHandler] 临时包处理器
*/
@MiraiInternalAPI
suspend
fun
addHandler
(
temporaryPacketHandler
:
TemporaryPacketHandler
<
*
,
*
>)
/**
...
...
@@ -67,7 +69,7 @@ interface BotNetworkHandler<Socket : DataPacketSocketAdapter> : CoroutineScope {
/**
* 关闭网络接口, 停止所有有关协程和任务
*/
suspend
fun
close
(
cause
:
Throwable
?
=
null
)
{
fun
close
(
cause
:
Throwable
?
=
null
)
{
supervisor
.
cancel
(
CancellationException
(
"handler closed"
,
cause
))
}
}
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt
View file @
770865ca
...
...
@@ -101,16 +101,14 @@ internal class TIMBotNetworkHandler internal constructor(coroutineContext: Corou
heartbeatJob
?.
join
()
}
override
suspend
fun
close
(
cause
:
Throwable
?)
{
override
fun
close
(
cause
:
Throwable
?)
{
super
.
close
(
cause
)
this
.
heartbeatJob
?.
cancel
(
CancellationException
(
"handler closed"
))
this
.
heartbeatJob
?.
join
()
//等待 cancel 完成
this
.
heartbeatJob
=
null
if
(!
this
.
loginResult
.
isCompleted
&&
!
this
.
loginResult
.
isCancelled
)
{
this
.
loginResult
.
cancel
(
CancellationException
(
"socket closed"
))
this
.
loginResult
.
join
()
}
this
.
socket
.
close
()
...
...
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