From aad1fb9230b23e6883c0639501476e2b9f8d3f9d Mon Sep 17 00:00:00 2001 From: RTAkland Date: Tue, 19 Nov 2024 16:51:14 +0800 Subject: [PATCH] feat[kritor]: add scheduler --- .../src/main/kotlin/cn/rtast/rob/kritor/BotInstance.kt | 4 ++++ .../src/main/kotlin/cn/rtast/rob/kritor/RKritorFactory.kt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ronebot-kritor/src/main/kotlin/cn/rtast/rob/kritor/BotInstance.kt b/ronebot-kritor/src/main/kotlin/cn/rtast/rob/kritor/BotInstance.kt index 53b47d3..fdab708 100644 --- a/ronebot-kritor/src/main/kotlin/cn/rtast/rob/kritor/BotInstance.kt +++ b/ronebot-kritor/src/main/kotlin/cn/rtast/rob/kritor/BotInstance.kt @@ -4,6 +4,7 @@ * Date: 2024/10/29 */ +@file:Suppress("unused") package cn.rtast.rob.kritor @@ -13,6 +14,7 @@ import cn.rtast.rob.kritor.kritor.KritorListener import cn.rtast.rob.kritor.util.InternalListener import cn.rtast.rob.kritor.util.authenticate import cn.rtast.rob.kritor.util.createAuthInterceptor +import cn.rtast.rob.scheduler.BotCoroutineScheduler import io.grpc.Channel import io.grpc.ClientInterceptors.intercept import io.grpc.ManagedChannel @@ -35,6 +37,8 @@ class BotInstance internal constructor( lateinit var action: KritorAction override val isActionInitialized = true + val scheduler = BotCoroutineScheduler(this) + override suspend fun createBot(): BotInstance { val channel = ManagedChannelBuilder .forAddress(host, port) diff --git a/ronebot-kritor/src/main/kotlin/cn/rtast/rob/kritor/RKritorFactory.kt b/ronebot-kritor/src/main/kotlin/cn/rtast/rob/kritor/RKritorFactory.kt index 875e929..25ed5bd 100644 --- a/ronebot-kritor/src/main/kotlin/cn/rtast/rob/kritor/RKritorFactory.kt +++ b/ronebot-kritor/src/main/kotlin/cn/rtast/rob/kritor/RKritorFactory.kt @@ -4,16 +4,20 @@ * Date: 2024/10/27 */ +@file:Suppress("unused") package cn.rtast.rob.kritor import cn.rtast.rob.BotFactory import cn.rtast.rob.kritor.kritor.KritorListener +import cn.rtast.rob.scheduler.GlobalCoroutineScheduler object RKritorFactory : BotFactory { val botInstances = mutableListOf() + val globalScheduler = GlobalCoroutineScheduler(botInstances) + suspend fun createClient( host: String, port: Int,