commit 24/09/2025

This commit is contained in:
2025-09-24 11:48:36 +07:00
parent 59dd67acc8
commit 55f6a24cce
7 changed files with 156 additions and 15 deletions

View File

@@ -18,6 +18,7 @@ import web.WebApp
import java.time.DayOfWeek
import java.time.LocalDate
import java.time.LocalTime
import kotlin.concurrent.fixedRateTimer
fun main() {
@@ -141,7 +142,7 @@ fun main() {
listOf(
Pair("admin", "password"),
Pair("user", "password")
), db
), db, StreamerOutputs
)
web.Start()
@@ -154,7 +155,7 @@ fun main() {
// belum create BarixConnection untuk ipaddress ini
Logger.info{"New Streamer Output connection from ${cmd.ipaddress}"}
if (_sc!=null){
val _bc = BarixConnection(_sc.channel,cmd.ipaddress)
val _bc = BarixConnection(_sc.index,_sc.channel,cmd.ipaddress)
_bc.vu = cmd.vu
_bc.bufferRemain = cmd.buffremain
_bc.statusData = cmd.statusdata
@@ -163,7 +164,7 @@ fun main() {
} else {
// sudah ada, update data
if (_sc !=null && !_sc.channel.equals(_streamer.channel)) {
if (_sc !=null && _sc.channel != _streamer.channel) {
_streamer.channel = _sc.channel
}
_streamer.vu = cmd.vu
@@ -173,5 +174,23 @@ fun main() {
}
val onlinechecker = fixedRateTimer(name="onlinecheck", initialDelay = 1000, period = 1000) {
// cek setiap 1 detik, decrement online counter semua BarixConnection
StreamerOutputs.values.forEach {
it.decrementOnlineCounter()
}
}
// shutdown hook
Runtime.getRuntime().addShutdownHook(Thread {
Logger.info{"Shutdown hook called, stopping services..."}
barixserver.StopTcpCommand()
onlinechecker.cancel()
web.Stop()
audioPlayer.Close()
db.close()
Logger.info{"All services stopped, exiting application."}
} )
}