mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-06-09 07:18:22 +00:00
Merge pull request #98 from dalbodeule/develop
command, ws ping message fix
This commit is contained in:
commit
b889599558
@ -92,7 +92,14 @@ object ChzzkHandler {
|
|||||||
if (!running) return@forEach
|
if (!running) return@forEach
|
||||||
try {
|
try {
|
||||||
val streamInfo = getStreamInfo(it.channel.channelId)
|
val streamInfo = getStreamInfo(it.channel.channelId)
|
||||||
if (streamInfo.content?.status == "OPEN" && !it.isActive) it.isActive(true, streamInfo)
|
if (streamInfo.content?.status == "OPEN" && !it.isActive) {
|
||||||
|
try {
|
||||||
|
if(it.channel.isBroadcasting)
|
||||||
|
it.isActive(true, streamInfo)
|
||||||
|
} catch(e: Exception) {
|
||||||
|
logger.info("Exception: ${e.stackTraceToString()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
if (streamInfo.content?.status == "CLOSE" && it.isActive) it.isActive(false, streamInfo)
|
if (streamInfo.content?.status == "CLOSE" && it.isActive) it.isActive(false, streamInfo)
|
||||||
} catch (e: SocketTimeoutException) {
|
} catch (e: SocketTimeoutException) {
|
||||||
logger.info("Thread 1 Timeout: ${it.channel.channelName} / ${e.stackTraceToString()}")
|
logger.info("Thread 1 Timeout: ${it.channel.channelName} / ${e.stackTraceToString()}")
|
||||||
@ -114,7 +121,14 @@ object ChzzkHandler {
|
|||||||
if (!running) return@forEach
|
if (!running) return@forEach
|
||||||
try {
|
try {
|
||||||
val streamInfo = getStreamInfo(it.channel.channelId)
|
val streamInfo = getStreamInfo(it.channel.channelId)
|
||||||
if (streamInfo.content?.status == "OPEN" && !it.isActive) it.isActive(true, streamInfo)
|
if (streamInfo.content?.status == "OPEN" && !it.isActive) {
|
||||||
|
try {
|
||||||
|
if(it.channel.isBroadcasting)
|
||||||
|
it.isActive(true, streamInfo)
|
||||||
|
} catch(e: Exception) {
|
||||||
|
logger.info("Exception: ${e.stackTraceToString()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
if (streamInfo.content?.status == "CLOSE" && it.isActive) it.isActive(false, streamInfo)
|
if (streamInfo.content?.status == "CLOSE" && it.isActive) it.isActive(false, streamInfo)
|
||||||
} catch (e: SocketTimeoutException) {
|
} catch (e: SocketTimeoutException) {
|
||||||
logger.info("Thread 2 Timeout: ${it.channel.channelName} / ${e.stackTraceToString()}")
|
logger.info("Thread 2 Timeout: ${it.channel.channelName} / ${e.stackTraceToString()}")
|
||||||
@ -169,7 +183,7 @@ class UserHandler(
|
|||||||
private var user: User,
|
private var user: User,
|
||||||
var streamStartTime: LocalDateTime?,
|
var streamStartTime: LocalDateTime?,
|
||||||
) {
|
) {
|
||||||
private lateinit var messageHandler: MessageHandler
|
private val messageHandler = MessageHandler(this@UserHandler)
|
||||||
private val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
|
private val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
|
||||||
private var _isActive: Boolean
|
private var _isActive: Boolean
|
||||||
get() = LiveStatusService.getLiveStatus(user)?.status ?: false
|
get() = LiveStatusService.getLiveStatus(user)?.status ?: false
|
||||||
@ -182,7 +196,6 @@ class UserHandler(
|
|||||||
.withChatListener(object : ChatEventListener {
|
.withChatListener(object : ChatEventListener {
|
||||||
override fun onConnect(chat: ChzzkChat, isReconnecting: Boolean) {
|
override fun onConnect(chat: ChzzkChat, isReconnecting: Boolean) {
|
||||||
logger.info("ChzzkChat connected. ${channel.channelName} - ${channel.channelId} / reconnected: $isReconnecting")
|
logger.info("ChzzkChat connected. ${channel.channelName} - ${channel.channelId} / reconnected: $isReconnecting")
|
||||||
messageHandler = MessageHandler(this@UserHandler)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(ex: Exception) {
|
override fun onError(ex: Exception) {
|
||||||
|
@ -58,12 +58,7 @@ class Discord: ListenerAdapter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val commands = listOf(
|
private val commands = listOf(
|
||||||
AddCommand,
|
|
||||||
AlertCommand,
|
|
||||||
PingCommand,
|
PingCommand,
|
||||||
HookComand,
|
|
||||||
RemoveCommand,
|
|
||||||
UpdateCommand,
|
|
||||||
AddManagerCommand,
|
AddManagerCommand,
|
||||||
ListManagerCommand,
|
ListManagerCommand,
|
||||||
RemoveManagerCommand,
|
RemoveManagerCommand,
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
package space.mori.chzzk_bot.chatbot.discord.commands
|
|
||||||
|
|
||||||
import net.dv8tion.jda.api.JDA
|
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData
|
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import space.mori.chzzk_bot.chatbot.chzzk.ChzzkHandler
|
|
||||||
import space.mori.chzzk_bot.chatbot.chzzk.Connector
|
|
||||||
import space.mori.chzzk_bot.chatbot.discord.CommandInterface
|
|
||||||
import space.mori.chzzk_bot.common.services.CommandService
|
|
||||||
import space.mori.chzzk_bot.common.services.ManagerService
|
|
||||||
import space.mori.chzzk_bot.common.services.UserService
|
|
||||||
|
|
||||||
object AddCommand : CommandInterface {
|
|
||||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
|
||||||
override val name: String = "add"
|
|
||||||
override val command = Commands.slash(name, "명령어를 추가합니다.")
|
|
||||||
.addOptions(OptionData(OptionType.STRING, "label", "작동할 명령어를 입력하세요.", true))
|
|
||||||
.addOptions(OptionData(OptionType.STRING, "content", "표시될 텍스트를 입력하세요.", true))
|
|
||||||
.addOptions(OptionData(OptionType.STRING, "fail_content", "카운터 업데이트 실패시 표시될 텍스트를 입력하세요.", false))
|
|
||||||
|
|
||||||
override fun run(event: SlashCommandInteractionEvent, bot: JDA) {
|
|
||||||
val label = event.getOption("label")?.asString
|
|
||||||
val content = event.getOption("content")?.asString
|
|
||||||
val failContent = event.getOption("fail_content")?.asString
|
|
||||||
|
|
||||||
if(label == null || content == null) {
|
|
||||||
event.hook.sendMessage("명령어와 텍스트는 필수 입력입니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var user = UserService.getUser(event.user.idLong)
|
|
||||||
val manager = event.guild?.idLong?.let { ManagerService.getUser(it, event.user.idLong) }
|
|
||||||
if(user == null && manager == null) {
|
|
||||||
event.hook.sendMessage("당신은 이 명령어를 사용할 수 없습니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (manager != null) {
|
|
||||||
transaction {
|
|
||||||
user = manager.user
|
|
||||||
}
|
|
||||||
user?.let { ManagerService.updateManager(it, event.user.idLong, event.user.effectiveName) }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user == null) {
|
|
||||||
event.hook.sendMessage("에러가 발생했습니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val commands = CommandService.getCommands(user!!)
|
|
||||||
if (commands.any { it.command == label }) {
|
|
||||||
event.hook.sendMessage("$label 명령어는 이미 있습니다! 업데이트 명령어를 써주세요.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val chzzkChannel = user!!.token?.let { Connector.getChannel(it) }
|
|
||||||
|
|
||||||
try {
|
|
||||||
CommandService.saveCommand(user!!, label, content, failContent ?: "")
|
|
||||||
try {
|
|
||||||
ChzzkHandler.reloadCommand(chzzkChannel!!)
|
|
||||||
} catch (_: Exception) {}
|
|
||||||
event.hook.sendMessage("등록이 완료되었습니다. $label = $content / $failContent").queue()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
event.hook.sendMessage("에러가 발생했습니다.").queue()
|
|
||||||
logger.debug(e.stackTraceToString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
package space.mori.chzzk_bot.chatbot.discord.commands
|
|
||||||
|
|
||||||
import net.dv8tion.jda.api.JDA
|
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData
|
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import space.mori.chzzk_bot.chatbot.chzzk.ChzzkHandler
|
|
||||||
import space.mori.chzzk_bot.chatbot.chzzk.Connector
|
|
||||||
import space.mori.chzzk_bot.chatbot.discord.CommandInterface
|
|
||||||
import space.mori.chzzk_bot.common.services.ManagerService
|
|
||||||
import space.mori.chzzk_bot.common.services.UserService
|
|
||||||
|
|
||||||
object AlertCommand : CommandInterface {
|
|
||||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
|
||||||
override val name: String = "alert"
|
|
||||||
override val command = Commands.slash(name, "방송알람 채널을 설정합니다. / 알람 취소도 이 명령어를 이용하세요!")
|
|
||||||
.addOptions(OptionData(OptionType.CHANNEL, "channel", "알림을 보낼 채널을 입력하세요."))
|
|
||||||
.addOptions(OptionData(OptionType.STRING, "content", "표시될 텍스트를 입력하세요. 비워두면 알람이 취소됩니다."))
|
|
||||||
|
|
||||||
override fun run(event: SlashCommandInteractionEvent, bot: JDA) {
|
|
||||||
val channel = event.getOption("channel")?.asChannel
|
|
||||||
val content = event.getOption("content")?.asString
|
|
||||||
|
|
||||||
var user = UserService.getUser(event.user.idLong)
|
|
||||||
val manager = event.guild?.idLong?.let { ManagerService.getUser(it, event.user.idLong) }
|
|
||||||
if(user == null && manager == null) {
|
|
||||||
event.hook.sendMessage("당신은 이 명령어를 사용할 수 없습니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (manager != null) {
|
|
||||||
transaction {
|
|
||||||
user = manager.user
|
|
||||||
}
|
|
||||||
user?.let { ManagerService.updateManager(it, event.user.idLong, event.user.effectiveName) }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user == null) {
|
|
||||||
event.hook.sendMessage("에러가 발생했습니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val chzzkChannel = user!!.token?.let { Connector.getChannel(it) }
|
|
||||||
|
|
||||||
try {
|
|
||||||
val newUser = UserService.updateLiveAlert(user!!, channel?.guild?.idLong ?: 0L, channel?.idLong ?: 0L, content ?: "")
|
|
||||||
try {
|
|
||||||
ChzzkHandler.reloadUser(chzzkChannel!!, newUser)
|
|
||||||
} catch (_: Exception) {}
|
|
||||||
event.hook.sendMessage("업데이트가 완료되었습니다.").queue()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
event.hook.sendMessage("에러가 발생했습니다.").queue()
|
|
||||||
logger.debug(e.stackTraceToString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
package space.mori.chzzk_bot.chatbot.discord.commands
|
|
||||||
|
|
||||||
import net.dv8tion.jda.api.JDA
|
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData
|
|
||||||
import org.koin.java.KoinJavaComponent.inject
|
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import space.mori.chzzk_bot.chatbot.discord.CommandInterface
|
|
||||||
import space.mori.chzzk_bot.common.events.CoroutinesEventBus
|
|
||||||
import space.mori.chzzk_bot.common.events.DiscordRegisterEvent
|
|
||||||
import space.mori.chzzk_bot.common.services.UserService
|
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
|
||||||
|
|
||||||
object HookComand: CommandInterface {
|
|
||||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
|
||||||
override val name = "hook"
|
|
||||||
override val command = Commands.slash(name, "디스코드 계정과 서버를 등록합니다.")
|
|
||||||
.addOptions(OptionData(OptionType.STRING, "token", "디스코드 연동 토큰을 입력해주세요."))
|
|
||||||
|
|
||||||
// key: Token, value: ChzzkID
|
|
||||||
private val hookMap = ConcurrentHashMap<String, String>()
|
|
||||||
private val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
|
|
||||||
|
|
||||||
init {
|
|
||||||
dispatcher.subscribe(DiscordRegisterEvent::class) {
|
|
||||||
hookMap[it.token] = it.user
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun run(event: SlashCommandInteractionEvent, bot: JDA) {
|
|
||||||
val token = event.getOption("token")?.asString
|
|
||||||
if(token == null) {
|
|
||||||
event.hook.sendMessage("Token은 필수 입력입니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val user = UserService.getUser(hookMap[token] ?: "")
|
|
||||||
|
|
||||||
if (user == null) {
|
|
||||||
event.hook.sendMessage("치지직 계정을 찾을 수 없습니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if(event.guild == null) {
|
|
||||||
event.hook.sendMessage("이 명령어는 디스코드 서버 안에서 실행해야 합니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
UserService.updateUser(user, event.user.idLong)
|
|
||||||
UserService.updateLiveAlert(user, event.guild!!.idLong, event.channelIdLong, "")
|
|
||||||
hookMap.remove(token)
|
|
||||||
event.hook.sendMessage("등록이 완료되었습니다. `${user.username}`").queue()
|
|
||||||
} catch(e: Exception) {
|
|
||||||
event.hook.sendMessage("에러가 발생했습니다.").queue()
|
|
||||||
logger.debug(e.stackTraceToString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package space.mori.chzzk_bot.chatbot.discord.commands
|
|
||||||
|
|
||||||
import net.dv8tion.jda.api.JDA
|
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData
|
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import space.mori.chzzk_bot.chatbot.chzzk.ChzzkHandler
|
|
||||||
import space.mori.chzzk_bot.chatbot.chzzk.Connector
|
|
||||||
import space.mori.chzzk_bot.chatbot.discord.CommandInterface
|
|
||||||
import space.mori.chzzk_bot.common.services.CommandService
|
|
||||||
import space.mori.chzzk_bot.common.services.ManagerService
|
|
||||||
import space.mori.chzzk_bot.common.services.UserService
|
|
||||||
|
|
||||||
object RemoveCommand : CommandInterface {
|
|
||||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
|
||||||
override val name: String = "remove"
|
|
||||||
override val command = Commands.slash(name, "명령어를 삭제합니다.")
|
|
||||||
.addOptions(OptionData(OptionType.STRING, "label", "삭제할 명령어를 입력하세요.", true))
|
|
||||||
|
|
||||||
override fun run(event: SlashCommandInteractionEvent, bot: JDA) {
|
|
||||||
val label = event.getOption("label")?.asString
|
|
||||||
|
|
||||||
if(label == null) {
|
|
||||||
event.hook.sendMessage("명령어는 필수 입력입니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var user = UserService.getUser(event.user.idLong)
|
|
||||||
val manager = event.guild?.idLong?.let { ManagerService.getUser(it, event.user.idLong) }
|
|
||||||
if(user == null && manager == null) {
|
|
||||||
event.hook.sendMessage("당신은 이 명령어를 사용할 수 없습니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (manager != null) {
|
|
||||||
transaction {
|
|
||||||
user = manager.user
|
|
||||||
}
|
|
||||||
user?.let { ManagerService.updateManager(it, event.user.idLong, event.user.effectiveName) }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user == null) {
|
|
||||||
event.hook.sendMessage("에러가 발생했습니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val chzzkChannel = user!!.token?.let { Connector.getChannel(it) }
|
|
||||||
|
|
||||||
try {
|
|
||||||
CommandService.removeCommand(user!!, label)
|
|
||||||
try {
|
|
||||||
ChzzkHandler.reloadCommand(chzzkChannel!!)
|
|
||||||
} catch (_: Exception) {}
|
|
||||||
event.hook.sendMessage("삭제가 완료되었습니다. $label").queue()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
event.hook.sendMessage("에러가 발생했습니다.").queue()
|
|
||||||
logger.debug(e.stackTraceToString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
package space.mori.chzzk_bot.chatbot.discord.commands
|
|
||||||
|
|
||||||
import net.dv8tion.jda.api.JDA
|
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData
|
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import space.mori.chzzk_bot.chatbot.chzzk.ChzzkHandler
|
|
||||||
import space.mori.chzzk_bot.chatbot.chzzk.Connector
|
|
||||||
import space.mori.chzzk_bot.chatbot.discord.CommandInterface
|
|
||||||
import space.mori.chzzk_bot.common.services.CommandService
|
|
||||||
import space.mori.chzzk_bot.common.services.ManagerService
|
|
||||||
import space.mori.chzzk_bot.common.services.UserService
|
|
||||||
|
|
||||||
object UpdateCommand : CommandInterface {
|
|
||||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
|
||||||
override val name: String = "update"
|
|
||||||
override val command = Commands.slash(name, "명령어를 수정합니다.")
|
|
||||||
.addOptions(OptionData(OptionType.STRING, "label", "수정할 명령어를 입력하세요.", true))
|
|
||||||
.addOptions(OptionData(OptionType.STRING, "content", "표시될 텍스트를 입력하세요.", true))
|
|
||||||
.addOptions(OptionData(OptionType.STRING, "fail_content", "카운터 업데이트 실패시 표시될 텍스트를 입력하세요.", false))
|
|
||||||
|
|
||||||
override fun run(event: SlashCommandInteractionEvent, bot: JDA) {
|
|
||||||
val label = event.getOption("label")?.asString
|
|
||||||
val content = event.getOption("content")?.asString
|
|
||||||
val failContent = event.getOption("fail_content")?.asString
|
|
||||||
|
|
||||||
if(label == null || content == null) {
|
|
||||||
event.hook.sendMessage("명령어와 텍스트는 필수 입력입니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var user = UserService.getUser(event.user.idLong)
|
|
||||||
val manager = event.guild?.idLong?.let { ManagerService.getUser(it, event.user.idLong) }
|
|
||||||
if(user == null && manager == null) {
|
|
||||||
event.hook.sendMessage("당신은 이 명령어를 사용할 수 없습니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (manager != null) {
|
|
||||||
transaction {
|
|
||||||
user = manager.user
|
|
||||||
}
|
|
||||||
user?.let { ManagerService.updateManager(it, event.user.idLong, event.user.effectiveName) }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user == null) {
|
|
||||||
event.hook.sendMessage("에러가 발생했습니다.").queue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val chzzkChannel = user!!.token?.let { Connector.getChannel(it) }
|
|
||||||
|
|
||||||
try {
|
|
||||||
CommandService.updateCommand(user!!, label, content, failContent ?: "")
|
|
||||||
chzzkChannel?.let { ChzzkHandler.reloadCommand(it) }
|
|
||||||
event.hook.sendMessage("등록이 완료되었습니다. $label = $content").queue()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
event.hook.sendMessage("에러가 발생했습니다.").queue()
|
|
||||||
logger.debug(e.stackTraceToString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -70,6 +70,10 @@ fun Routing.wsSongListRoutes() {
|
|||||||
for (frame in incoming) {
|
for (frame in incoming) {
|
||||||
when(frame) {
|
when(frame) {
|
||||||
is Frame.Text -> {
|
is Frame.Text -> {
|
||||||
|
if(frame.readText() == "ping") {
|
||||||
|
send(Frame.Pong(frame.data))
|
||||||
|
return@webSocket
|
||||||
|
}
|
||||||
val data = frame.readText().let { Json.decodeFromString<SongRequest>(it) }
|
val data = frame.readText().let { Json.decodeFromString<SongRequest>(it) }
|
||||||
|
|
||||||
if(data.maxQueue != null && data.maxQueue > 0) SongConfigService.updateQueueLimit(user, data.maxQueue)
|
if(data.maxQueue != null && data.maxQueue > 0) SongConfigService.updateQueueLimit(user, data.maxQueue)
|
||||||
|
@ -63,7 +63,10 @@ fun Routing.wsSongRoutes() {
|
|||||||
for (frame in incoming) {
|
for (frame in incoming) {
|
||||||
when(frame) {
|
when(frame) {
|
||||||
is Frame.Text -> {
|
is Frame.Text -> {
|
||||||
|
if(frame.readText() == "ping") {
|
||||||
|
send(Frame.Pong(frame.data))
|
||||||
|
return@webSocket
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is Frame.Ping -> send(Frame.Pong(frame.data))
|
is Frame.Ping -> send(Frame.Pong(frame.data))
|
||||||
else -> {
|
else -> {
|
||||||
|
@ -63,7 +63,10 @@ fun Routing.wsTimerRoutes() {
|
|||||||
for (frame in incoming) {
|
for (frame in incoming) {
|
||||||
when(frame) {
|
when(frame) {
|
||||||
is Frame.Text -> {
|
is Frame.Text -> {
|
||||||
|
if(frame.readText() == "ping") {
|
||||||
|
send(Frame.Pong(frame.data))
|
||||||
|
return@webSocket
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is Frame.Ping -> send(Frame.Pong(frame.data))
|
is Frame.Ping -> send(Frame.Pong(frame.data))
|
||||||
else -> {
|
else -> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user