Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复因握手阶段的错误导致bot无法接受后续连接的问题 #110

Merged
merged 2 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions onebot/src/main/kotlin/client/connection/ConnectFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ package cn.evolvefield.onebot.client.connection
import cn.evolvefield.onebot.client.config.BotConfig
import cn.evolvefield.onebot.client.core.Bot
import cn.evolvefield.onebot.client.handler.ActionHandler
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Job
import kotlinx.coroutines.*
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.net.InetSocketAddress
Expand All @@ -24,7 +21,7 @@ import java.net.URI
*/
class ConnectFactory private constructor(
private val config: BotConfig,
parent: Job?,
private val parent: Job?,
private val logger: Logger,
) {
private val actionHandler: ActionHandler = ActionHandler(parent, logger)
Expand Down Expand Up @@ -96,8 +93,9 @@ class ConnectFactory private constructor(

@JvmOverloads
fun createProducer(
scope: CoroutineScope = CoroutineScope(CoroutineName("ConnectFactory"))
scope0: CoroutineScope = CoroutineScope(CoroutineName("ConnectFactory"))
): OneBotProducer {
val scope = if (parent == null) scope0 else scope0 + parent
if (config.isInReverseMode) {
val address = InetSocketAddress(config.reversedPort)
return ReversedOneBotProducer(WSServer.create(scope, config, address, logger, actionHandler, config.token))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Overflow : IMirai, CoroutineScope, LowLevelApiAccessor, OverflowAPI {
File(System.getProperty("overflow.config", "overflow.json"))
}
val defaultJob: Job? by lazy {
if (!miraiConsole) return@lazy null
if (!miraiConsole) return@lazy SupervisorJob()
return@lazy MiraiConsole.job
}
val config: Config by lazy {
Expand Down
Loading