some change on TimerEvents.

This commit is contained in:
dalbodeule
2024-07-30 23:00:29 +09:00
parent a9ee40e936
commit 99ec9ba7a0
3 changed files with 11 additions and 6 deletions

View File

@@ -3,7 +3,10 @@ package space.mori.chzzk_bot.webserver.routes
import io.ktor.server.routing.*
import io.ktor.server.websocket.*
import io.ktor.websocket.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.launch
import kotlinx.serialization.Serializable
import space.mori.chzzk_bot.common.events.Event
import space.mori.chzzk_bot.common.events.TimerType
@@ -52,8 +55,10 @@ fun Routing.wsTimerRoutes() {
val dispatcher = EventDispatcher
dispatcher.register(TimerEvent::class.java, object : EventHandler<TimerEvent> {
override suspend fun handle(event: TimerEvent) {
sessions[event.uid]?.sendSerialized(TimerResponse(event.type, event.time ?: ""))
override fun handle(event: TimerEvent) {
CoroutineScope(Dispatchers.IO).launch {
sessions[event.uid]?.sendSerialized(TimerResponse(event.type, event.time ?: ""))
}
}
})
}