commit 03/02/2026

This commit is contained in:
2026-02-03 17:02:08 +07:00
parent b90982366d
commit b78832451a
43 changed files with 954 additions and 305 deletions

View File

@@ -72,11 +72,18 @@ class TCP_Android_Command_Server {
//println("Received command from $key : $str")
str.split("@").map { it.trim() }.filter { ValidString(it) }
.forEach {
Logger.info{"Receive command from $key : $it"}
process_command(key,it) { reply ->
try {
dout.write(String_to_Byte_Android(reply))
val cc = String_to_Byte_Android(reply)
if (cc.isNotEmpty()){
dout.write(cc)
dout.flush()
Logger.info{"Sent reply ${cc.size} bytes to $key : $reply"}
} else Logger.error { "Empty reply to send to $key" }
} catch (e: Exception) {
logcb.accept("Failed to send reply to $key, Message : $e")
logcb.accept("Send reply to $key failed, reply=$reply, Message : $e")
}
}
}
@@ -122,12 +129,14 @@ class TCP_Android_Command_Server {
*/
private fun String_to_Byte_Android(str: String): ByteArray {
if (ValidString(str)) {
val bytes = str.toByteArray(Charsets.UTF_8)
val len = bytes.size
val bytes = str.toByteArray()
val len = str.length
return ByteBuffer.allocate(len + 4)
.order(ByteOrder.LITTLE_ENDIAN)
.putInt(len)
.put(bytes)
.putInt(0,len)
.put(4,bytes)
.array()
}
return ByteArray(0)
@@ -169,6 +178,11 @@ class TCP_Android_Command_Server {
}
}
"PING" -> {
// simple ping command
cb.accept("PONG@")
}
"PCMFILE_START" ->{
// start sending PCM data from Android for paging
val size = parts.getOrElse(1) { "0" }.toInt()
@@ -211,6 +225,7 @@ class TCP_Android_Command_Server {
Logger.info { "Paging job closed from Android $key, total bytes received ${data.size}, writing to file ${pj.filePath.absolutePathString()}" }
val result = audioPlayer.WavWriter(data, pj.filePath.absolutePathString(), true)
if (result.success) {
Logger.info{"Paging audio file written from Android $key to ${pj.filePath.absolutePathString()}"}
val qp = QueuePaging(
0u,
LocalDateTime.now().format(datetimeformat1),
@@ -219,6 +234,7 @@ class TCP_Android_Command_Server {
pj.filePath.absolutePathString(),
pj.broadcastzones
)
Logger.info{"Inserting paging audio to queue paging table from Android $key, data=$qp"}
if (db.queuepagingDB.Add(qp)) {
db.queuepagingDB.Resort()
logcb.accept("Paging audio inserted to queue paging table from Android $key, file ${pj.filePath.absolutePathString()}")
@@ -334,8 +350,10 @@ class TCP_Android_Command_Server {
.forEach { annid ->
// masukin ke VARMESSAGES yang unik secara ANN_ID dan Language
val xx = db.messageDB.List
.filter{ it.ANN_ID == annid.toUInt() }
.asSequence()
.filter{it.ANN_ID == annid.toUInt()}
.distinctBy { it.ANN_ID }
VARMESSAGES.addAll(xx)
}
result.append(VARMESSAGES.size).append("@")