mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-06-09 07:18:22 +00:00
debug some errors.
- wsSongListRoutes to isNotEmpty(), access list[0] - ChzzkHandler.runStreamInfo debugs with startThread functions.
This commit is contained in:
parent
355b56a6cf
commit
f994972fac
@ -124,16 +124,32 @@ object ChzzkHandler {
|
||||
}
|
||||
}
|
||||
|
||||
fun startThread(name: String, runner: Runnable) {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
while(running) {
|
||||
try {
|
||||
val thread = Thread(runner, name)
|
||||
thread.start()
|
||||
thread.join()
|
||||
} catch(e: Exception) {
|
||||
logger.error("Thread $name Exception: ${e.stackTraceToString()}")
|
||||
}
|
||||
if(running) {
|
||||
logger.info("Thread $name restart in 5 seconds")
|
||||
delay(5000)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 첫 번째 스레드 시작
|
||||
val thread1 = Thread(threadRunner1, "Chzzk-StreamInfo-1")
|
||||
thread1.start()
|
||||
startThread("Chzzk-StreamInfo-1", threadRunner1)
|
||||
|
||||
// 85초 대기 후 두 번째 스레드 시작
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
delay(85000) // 85초 대기
|
||||
delay(95000) // start with 95 secs after.
|
||||
if (running) {
|
||||
val thread2 = Thread(threadRunner2, "Chzzk-StreamInfo-2")
|
||||
thread2.start()
|
||||
startThread("Chzzk-StreamInfo-2", threadRunner2)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -208,6 +224,7 @@ class UserHandler(
|
||||
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
if(!_isActive) {
|
||||
_isActive = true
|
||||
when(TimerConfigService.getConfig(UserService.getUser(channel.channelId)!!)?.option) {
|
||||
TimerType.UPTIME.value -> dispatcher.post(
|
||||
TimerEvent(
|
||||
@ -238,6 +255,7 @@ class UserHandler(
|
||||
logger.info("${user.username} is offline.")
|
||||
streamStartTime = null
|
||||
listener.closeAsync()
|
||||
_isActive = false
|
||||
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
val events = listOf(
|
||||
@ -257,9 +275,9 @@ class UserHandler(
|
||||
null
|
||||
)
|
||||
)
|
||||
|
||||
events.forEach { dispatcher.post(it) }
|
||||
}
|
||||
}
|
||||
_isActive = value
|
||||
}
|
||||
}
|
@ -121,18 +121,23 @@ fun Routing.wsSongListRoutes() {
|
||||
data.url
|
||||
))
|
||||
} else if(data.type == SongType.NEXT.value) {
|
||||
val song = SongListService.getSong(user)[0]
|
||||
SongListService.deleteSong(user, song.uid, song.name)
|
||||
dispatcher.post(SongEvent(
|
||||
user.token!!,
|
||||
SongType.NEXT,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
))
|
||||
val songList = SongListService.getSong(user)
|
||||
if(songList.isNotEmpty()) {
|
||||
val song = songList[0]
|
||||
SongListService.deleteSong(user, song.uid, song.name)
|
||||
dispatcher.post(
|
||||
SongEvent(
|
||||
user.token!!,
|
||||
SongType.NEXT,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
is Frame.Ping -> send(Frame.Pong(frame.data))
|
||||
|
Loading…
x
Reference in New Issue
Block a user