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
23057b11
Commit
23057b11
authored
Nov 26, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add timeout
parent
9bb11dba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt
....mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt
+10
-2
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt
View file @
23057b11
...
@@ -25,6 +25,7 @@ import net.mamoe.mirai.utils.OnlineStatus
...
@@ -25,6 +25,7 @@ import net.mamoe.mirai.utils.OnlineStatus
import
net.mamoe.mirai.utils.io.*
import
net.mamoe.mirai.utils.io.*
import
kotlin.coroutines.CoroutineContext
import
kotlin.coroutines.CoroutineContext
import
kotlin.properties.Delegates
import
kotlin.properties.Delegates
import
kotlin.random.Random
/**
/**
* 包处理协程调度器.
* 包处理协程调度器.
...
@@ -69,10 +70,12 @@ internal class TIMBotNetworkHandler internal constructor(coroutineContext: Corou
...
@@ -69,10 +70,12 @@ internal class TIMBotNetworkHandler internal constructor(coroutineContext: Corou
override
suspend
fun
login
(
configuration
:
BotConfiguration
):
LoginResult
{
override
suspend
fun
login
(
configuration
:
BotConfiguration
):
LoginResult
{
userContext
=
coroutineContext
userContext
=
coroutineContext
return
withContext
(
this
.
coroutineContext
)
{
return
withContext
(
this
.
coroutineContext
)
{
TIMProtocol
.
SERVER_IP
.
forEach
{
ip
->
TIMProtocol
.
SERVER_IP
.
sortedBy
{
Random
.
nextInt
()
}.
forEach
{
ip
->
bot
.
logger
.
info
(
"Connecting server $ip"
)
bot
.
logger
.
info
(
"Connecting server $ip"
)
try
{
try
{
socket
=
BotSocketAdapter
(
ip
,
configuration
)
withTimeout
(
3000
)
{
socket
=
BotSocketAdapter
(
ip
,
configuration
)
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
return
@
withContext
LoginResult
.
NETWORK_UNAVAILABLE
return
@
withContext
LoginResult
.
NETWORK_UNAVAILABLE
}
}
...
@@ -447,6 +450,11 @@ internal class TIMBotNetworkHandler internal constructor(coroutineContext: Corou
...
@@ -447,6 +450,11 @@ internal class TIMBotNetworkHandler internal constructor(coroutineContext: Corou
this
.
token00BA
=
packet
.
token00BA
this
.
token00BA
=
packet
.
token00BA
if
(
packet
.
transmissionCompleted
)
{
if
(
packet
.
transmissionCompleted
)
{
if
(
configuration
.
failOnCaptcha
)
{
loginResult
.
complete
(
LoginResult
.
CAPTCHA
)
close
()
return
}
val
code
=
configuration
.
captchaSolver
(
bot
,
captchaCache
!!
)
val
code
=
configuration
.
captchaSolver
(
bot
,
captchaCache
!!
)
this
.
captchaCache
=
null
this
.
captchaCache
=
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