mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-06-09 07:18:22 +00:00
debugs...
This commit is contained in:
parent
9396e69570
commit
768eadd561
@ -65,7 +65,7 @@ fun Routing.wsSongListRoutes() {
|
|||||||
}
|
}
|
||||||
delay(100) // Check every 100 ms
|
delay(100) // Check every 100 ms
|
||||||
}
|
}
|
||||||
return false // Timeoutㅌ
|
return false // Timeout
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun sendWithRetry(uid: String, res: SongResponse, maxRetries: Int = 5, delayMillis: Long = 3000L) {
|
suspend fun sendWithRetry(uid: String, res: SongResponse, maxRetries: Int = 5, delayMillis: Long = 3000L) {
|
||||||
@ -75,11 +75,15 @@ fun Routing.wsSongListRoutes() {
|
|||||||
while (attempt < maxRetries && !sentSuccessfully) {
|
while (attempt < maxRetries && !sentSuccessfully) {
|
||||||
val ws = sessions[uid]
|
val ws = sessions[uid]
|
||||||
try {
|
try {
|
||||||
|
if(ws == null) {
|
||||||
|
delay(delayMillis)
|
||||||
|
continue
|
||||||
|
}
|
||||||
// Attempt to send the message
|
// Attempt to send the message
|
||||||
ws?.sendSerialized(res)
|
ws.sendSerialized(res)
|
||||||
logger.debug("Message sent successfully to $uid on attempt $attempt")
|
logger.debug("Message sent successfully to $uid on attempt $attempt")
|
||||||
// Wait for ACK
|
// Wait for ACK
|
||||||
val ackReceived = ws?.let { waitForAck(it, res.type) }
|
val ackReceived = waitForAck(ws, res.type)
|
||||||
if (ackReceived == true) {
|
if (ackReceived == true) {
|
||||||
sentSuccessfully = true
|
sentSuccessfully = true
|
||||||
} else {
|
} else {
|
||||||
@ -129,7 +133,7 @@ fun Routing.wsSongListRoutes() {
|
|||||||
for (frame in incoming) {
|
for (frame in incoming) {
|
||||||
when (frame) {
|
when (frame) {
|
||||||
is Text -> {
|
is Text -> {
|
||||||
if (frame.readText() == "ping") {
|
if (frame.readText().trim() == "ping") {
|
||||||
send("pong")
|
send("pong")
|
||||||
} else {
|
} else {
|
||||||
val data = frame.readText().let { Json.decodeFromString<SongRequest>(it) }
|
val data = frame.readText().let { Json.decodeFromString<SongRequest>(it) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user