commit 07/10/2025
This commit is contained in:
@@ -3,6 +3,7 @@ package commandServer
|
||||
import audioPlayer
|
||||
import codes.Somecodes.Companion.ValidString
|
||||
import codes.Somecodes.Companion.datetimeformat1
|
||||
import content.Category
|
||||
import content.Language
|
||||
import database.Messagebank
|
||||
import database.QueuePaging
|
||||
@@ -16,6 +17,7 @@ import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.tinylog.Logger
|
||||
import tcpreceiver
|
||||
import udpreceiver
|
||||
import java.net.ServerSocket
|
||||
import java.net.Socket
|
||||
@@ -167,102 +169,158 @@ class TCP_Android_Command_Server {
|
||||
}
|
||||
}
|
||||
|
||||
"PCMFILE_START","STARTPAGINGAND" -> {
|
||||
//TODO Paging IPM1 success, Paging IPMT gagal
|
||||
"PCMFILE_START" ->{
|
||||
// start sending PCM data from Android for paging
|
||||
val size = parts.getOrElse(1) { "0" }.toInt()
|
||||
val filename = parts.getOrElse(2) { "" }
|
||||
val zones = parts.getOrElse(3) { "" }.replace(",",";")
|
||||
if (size>0){
|
||||
if (ValidString(filename)){
|
||||
if (ValidString(zones)){
|
||||
// create paging job
|
||||
val pj = PagingJob(key, zones)
|
||||
// ada expected size
|
||||
pj.expectedSize = size
|
||||
// masukin ke list
|
||||
listOnGoingPaging[key] = pj
|
||||
Logger.info{"PagingJob created for Android $key, zones: $zones, file: ${pj.filePath.absolutePathString()}"}
|
||||
|
||||
tcpreceiver.RequestDataFrom(key) {
|
||||
// push data ke paging job
|
||||
pj.addData(it, it.size)
|
||||
}
|
||||
cb.accept("PCMFILE_START;OK@")
|
||||
Logger.info{"Android $key start sending PCM data, expecting $size bytes"}
|
||||
return
|
||||
|
||||
} else logcb.accept("PCMFILE_START from Android $key failed, empty zones")
|
||||
} else logcb.accept("PCMFILE_START from Android $key failed, empty filename")
|
||||
} else logcb.accept("PCMFILE_START from Android $key failed, invalid size")
|
||||
cb.accept("PCMFILE_START;NG@")
|
||||
}
|
||||
"PCMFILE_STOP" -> {
|
||||
// stop sending PCM data from Android for paging
|
||||
val pj = listOnGoingPaging[key]
|
||||
if (pj!=null) {
|
||||
listOnGoingPaging.remove(key)
|
||||
tcpreceiver.StopRequestDataFrom(key)
|
||||
// get remaining data
|
||||
val data = pj.GetData()
|
||||
pj.Close()
|
||||
if (data.size==pj.expectedSize){
|
||||
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) {
|
||||
val qp = QueuePaging(
|
||||
0u,
|
||||
LocalDateTime.now().format(datetimeformat1),
|
||||
"ANDROID",
|
||||
"PAGING",
|
||||
pj.filePath.absolutePathString(),
|
||||
pj.broadcastzones
|
||||
)
|
||||
if (db.queuepagingDB.Add(qp)) {
|
||||
logcb.accept("Paging audio inserted to queue paging table from Android $key, file ${pj.filePath.absolutePathString()}")
|
||||
cb.accept("PCMFILE_STOP;OK@")
|
||||
return
|
||||
} else logcb.accept("Failed to insert paging audio to queue paging table from Android $key, file ${pj.filePath.absolutePathString()}")
|
||||
} else logcb.accept("Failed to write paging audio to file ${pj.filePath.absolutePathString()}, Message : ${result.message}")
|
||||
} else logcb.accept("PCMFILE_STOP from Android $key received size ${data.size} does not match expected ${pj.expectedSize}")
|
||||
} else logcb.accept("PCMFILE_STOP from Android $key failed, no ongoing PCM data receiving")
|
||||
cb.accept("PCMFILE_STOP;NG@")
|
||||
}
|
||||
|
||||
"STARTPAGINGAND" -> {
|
||||
// Start Paging request from IPM
|
||||
val zones = parts.getOrElse(1) { "" }.replace(",",";")
|
||||
if (ValidString(zones)){
|
||||
// create pagingjob
|
||||
val pj = PagingJob(key, zones)
|
||||
// masukin ke list
|
||||
listOnGoingPaging[key] = pj
|
||||
Logger.info{"PagingJob created for Android $key, zones: $zones, file: ${pj.filePath.absolutePathString()}"}
|
||||
Logger.info{"PagingJob created for IPM $key, zones: $zones, file: ${pj.filePath.absolutePathString()}"}
|
||||
|
||||
// start minta data dari udpreceiver
|
||||
udpreceiver.RequestDataFrom(key){
|
||||
// push data ke paging job
|
||||
pj.addData(it, it.size)
|
||||
}
|
||||
logcb.accept("Paging started from Android $key")
|
||||
cb.accept(parts[0]+";OK@")
|
||||
logcb.accept("Paging started from IPM $key")
|
||||
cb.accept("STARTPAGINGAND;OK@")
|
||||
return
|
||||
} else logcb.accept("Paging start from Android $key failed, empty zones")
|
||||
cb.accept(parts[0]+";NG@")
|
||||
} else logcb.accept("Paging start from IPM $key failed, empty zones")
|
||||
cb.accept("STARTPAGINGAND;NG@")
|
||||
}
|
||||
|
||||
"PCMFILE_STOP","STOPPAGINGAND" -> {
|
||||
// TODO Paging IPM1 success, Paging IPMT gagal
|
||||
"STOPPAGINGAND" -> {
|
||||
// stop paging request from IPM
|
||||
val pj = listOnGoingPaging[key]
|
||||
if (pj!=null){
|
||||
listOnGoingPaging.remove(key)
|
||||
udpreceiver.StopRequestDataFrom(key)
|
||||
logcb.accept("Paging stopped from Android $key")
|
||||
cb.accept(parts[0]+";OK@")
|
||||
logcb.accept("Paging stopped from IPM $key")
|
||||
// get remaining data
|
||||
val data = pj.GetData()
|
||||
pj.Close()
|
||||
Logger.info{"Paging job closed from Android $key, total bytes received ${data.size}, writing to file ${pj.filePath.absolutePathString()}"}
|
||||
Logger.info{"Paging job closed from IPM $key, total bytes received ${data.size}, writing to file ${pj.filePath.absolutePathString()}"}
|
||||
val result = audioPlayer.WavWriter(data, pj.filePath.absolutePathString(), true)
|
||||
if (result.success){
|
||||
val qp = QueuePaging(
|
||||
0u,
|
||||
LocalDateTime.now().format(datetimeformat1),
|
||||
"IPM",
|
||||
"PAGING",
|
||||
"NORMAL",
|
||||
pj.filePath.absolutePathString(),
|
||||
pj.broadcastzones
|
||||
)
|
||||
if (db.queuepagingDB.Add(qp)){
|
||||
logcb.accept("Paging audio inserted to queue paging table from Android $key, file ${pj.filePath.absolutePathString()}")
|
||||
cb.accept(parts[0]+";OK@")
|
||||
} else {
|
||||
logcb.accept("Failed to insert paging audio to queue paging table from Android $key, file ${pj.filePath.absolutePathString()}")
|
||||
cb.accept(parts[0]+";NG@")
|
||||
}
|
||||
} else {
|
||||
logcb.accept("Failed to write paging audio to file ${pj.filePath.absolutePathString()}, Message : ${result.message}")
|
||||
cb.accept(parts[0]+";NG@")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
logcb.accept("Paging stop from Android $key failed, no ongoing paging")
|
||||
cb.accept(parts[0]+";NG@")
|
||||
}
|
||||
logcb.accept("Paging audio inserted to queue paging table from IPM $key, file ${pj.filePath.absolutePathString()}")
|
||||
cb.accept("STOPPAGINGAND;OK@")
|
||||
return
|
||||
} else logcb.accept("Failed to insert paging audio to queue paging table from IPM $key, file ${pj.filePath.absolutePathString()}")
|
||||
} else logcb.accept("Failed to write paging audio to file ${pj.filePath.absolutePathString()}, Message : ${result.message}")
|
||||
} else logcb.accept("Paging stop from IPM $key failed, no ongoing paging")
|
||||
cb.accept("STOPPAGINGAND;NG@")
|
||||
|
||||
}
|
||||
|
||||
"CANCELPAGINGAND" -> {
|
||||
// TODO Cancel Paging IPM1 success, IPMT gagal
|
||||
// cancel paging request from IPM
|
||||
val pj = listOnGoingPaging[key]
|
||||
if (pj!=null){
|
||||
pj.Close()
|
||||
listOnGoingPaging.remove(key)
|
||||
udpreceiver.StopRequestDataFrom(key)
|
||||
logcb.accept("Paging from Android $key cancelled")
|
||||
logcb.accept("Paging from IPM $key cancelled")
|
||||
cb.accept("CANCELPAGINGAND;OK@")
|
||||
return
|
||||
} else logcb.accept("Paging cancel from Android $key failed, no ongoing paging")
|
||||
} else logcb.accept("Paging cancel from IPM $key failed, no ongoing paging")
|
||||
cb.accept("CANCELPAGINGAND;NG@")
|
||||
|
||||
}
|
||||
|
||||
"STARTINITIALIZE" -> {
|
||||
// TODO STARTINITIALIZE IPM1 success, IPMT gagal
|
||||
val username = parts.getOrElse(1) { "" }
|
||||
if (ValidString(username)){
|
||||
val userlogin = listUserLogin.find { it.username == username }
|
||||
if (userlogin != null){
|
||||
val userdb = db.userDB.List.find { it.username == username }
|
||||
if (userdb != null){
|
||||
println("Sending initialization data to $key with username $username")
|
||||
val result = StringBuilder()
|
||||
// kirim Zone
|
||||
result.append("ZONE")
|
||||
userdb.broadcastzones.split(";").map { it.trim() }.filter { it.isNotBlank() }.forEach {
|
||||
result.append(";")
|
||||
result.append(it)
|
||||
}
|
||||
result.append("@")
|
||||
cb.accept(result.toString())
|
||||
|
||||
// kirim MSGTOTAL
|
||||
result.clear()
|
||||
val VARMESSAGES = mutableListOf<Messagebank>()
|
||||
result.append("MSGTOTAL;")
|
||||
userdb.messagebank_ann_id
|
||||
// messagebank_ann_id adalah rentengan ANN_ID (digit) yang dipisah dengan ;
|
||||
.split(";")
|
||||
@@ -270,112 +328,272 @@ class TCP_Android_Command_Server {
|
||||
.map { it.trim() }
|
||||
// bukan string kosong antar dua tanda ;
|
||||
.filter { it.isNotBlank() }
|
||||
// beneran digit semua
|
||||
.filter { xx -> xx.all{it.isDigit()} }
|
||||
// iterasi setiap ANN_ID
|
||||
.forEach { annid ->
|
||||
// masukin ke VARMESSAGES yang unik secara ANN_ID dan Language
|
||||
val xx = db.messageDB.List
|
||||
.filter{ it.ANN_ID == annid.toUInt() }
|
||||
.distinctBy { it.Language }
|
||||
.distinctBy { it.ANN_ID }
|
||||
VARMESSAGES.addAll(xx)
|
||||
}
|
||||
result.append("MSGTOTAL;").append(VARMESSAGES.size).append("@")
|
||||
// VAR AP TOTAL
|
||||
val VARAPTOTAL = mutableListOf<Soundbank>()
|
||||
val al_split = userdb.airline_tags.split(";").map { it.trim() }.filter { it.isNotBlank() }
|
||||
al_split.forEach {
|
||||
val sb = db.Find_Soundbank_AirplaneName(it).firstOrNull()
|
||||
if (sb != null) VARAPTOTAL.add(sb)
|
||||
}
|
||||
result.append("VARAPTOTAL;").append(VARAPTOTAL.size).append("@")
|
||||
// VAR CITY TOTAL
|
||||
val VARCITYTOTAL = mutableListOf<Soundbank>()
|
||||
val ct_split = userdb.city_tags.split(";").map { it.trim() }.filter { it.isNotBlank() }
|
||||
ct_split.forEach {
|
||||
val sb = db.Find_Soundbank_City(it).firstOrNull()
|
||||
if (sb != null) VARCITYTOTAL.add(sb)
|
||||
}
|
||||
result.append("VARCITYTOTAL;").append(VARCITYTOTAL.size).append("@")
|
||||
// VAR PLACES TOTAL
|
||||
val VARPLACESTOTAL = mutableListOf<Soundbank>()
|
||||
// sb_split.forEach {
|
||||
// val sb = db.Find_Soundbank_Places(it).firstOrNull()
|
||||
// if (sb != null) VARPLACESTOTAL.add(sb)
|
||||
// }
|
||||
result.append("VARPLACESTOTAL;").append(VARPLACESTOTAL.size).append("@")
|
||||
// VAR SHALAT TOTAL
|
||||
val VARSHALATTOTAL = mutableListOf<Soundbank>()
|
||||
// sb_split.forEach {
|
||||
// val sb = db.Find_Soundbank_Shalat(it).firstOrNull()
|
||||
// if (sb != null) VARSHALATTOTAL.add(sb)
|
||||
// }
|
||||
result.append("VARSHALATTOTAL;").append(VARSHALATTOTAL.size).append("@")
|
||||
// VAR SEQUENCE TOTAL
|
||||
val VARSEQUENCETOTAL = mutableListOf<Soundbank>()
|
||||
// sb_split.forEach {
|
||||
// val sb = db.Find_Soundbank_Sequence(it).firstOrNull()
|
||||
// if (sb != null) VARSEQUENCETOTAL.add(sb)
|
||||
// }
|
||||
// VAR REASON TOTAL
|
||||
val VARREASONTOTAL = mutableListOf<Soundbank>()
|
||||
// sb_split.forEach {
|
||||
// val sb = db.Find_Soundbank_Reason(it).firstOrNull()
|
||||
// if (sb != null) VARREASONTOTAL.add(sb)
|
||||
// }
|
||||
result.append("VARREASONTOTAL;").append(VARREASONTOTAL.size).append("@")
|
||||
// VAR PROCEDURE TOTAL
|
||||
val VARPROCEDURETOTAL = mutableListOf<Soundbank>()
|
||||
// sb_split.forEach {
|
||||
// val sb = db.Find_Soundbank_Procedure(it).firstOrNull()
|
||||
// if (sb != null) VARPROCEDURETOTAL.add(sb)
|
||||
// }
|
||||
result.append("VARPROCEDURETOTAL;").append(VARPROCEDURETOTAL.size).append("@")
|
||||
// send to sender
|
||||
result.append(VARMESSAGES.size).append("@")
|
||||
cb.accept(result.toString())
|
||||
|
||||
// kirim VARAPTOTAL
|
||||
result.clear()
|
||||
result.append("VARAPTOTAL;")
|
||||
val VARAPTOTAL = mutableListOf<Soundbank>()
|
||||
userdb.airline_tags
|
||||
.split(";")
|
||||
.map { it.trim() }
|
||||
.filter { it.isNotBlank() }
|
||||
.forEach { al ->
|
||||
val sb = db.soundDB.List
|
||||
.filter { it.Category.equals(Category.Airplane_Name.name, true) }
|
||||
.filter { it.TAG.equals(al, true)}
|
||||
.distinctBy { it.TAG }
|
||||
VARAPTOTAL.addAll(sb)
|
||||
}
|
||||
result.append(VARAPTOTAL.size).append("@")
|
||||
cb.accept(result.toString())
|
||||
|
||||
// kirim VARCITYTOTAL
|
||||
result.clear()
|
||||
result.append("VARCITYTOTAL;")
|
||||
val VARCITYTOTAL = mutableListOf<Soundbank>()
|
||||
userdb.city_tags
|
||||
.split(";")
|
||||
.map { it.trim() }
|
||||
.filter { it.isNotBlank() }
|
||||
.forEach { ct ->
|
||||
val sb = db.soundDB.List
|
||||
.filter { it.Category.equals(Category.City.name, true) }
|
||||
.filter { it.TAG.equals(ct, true)}
|
||||
.distinctBy { it.TAG }
|
||||
VARCITYTOTAL.addAll(sb)
|
||||
}
|
||||
result.append(VARCITYTOTAL.size).append("@")
|
||||
cb.accept(result.toString())
|
||||
|
||||
// kirim VARPLACESTOTAL
|
||||
result.clear()
|
||||
result.append("VARPLACESTOTAL;")
|
||||
val VARPLACESTOTAL = mutableListOf<Soundbank>()
|
||||
db.soundDB.List
|
||||
.filter { it.Category.equals(Category.Places.name, true) }
|
||||
.distinctBy { it.TAG }
|
||||
.forEach {
|
||||
VARPLACESTOTAL.add(it)
|
||||
}
|
||||
result.append(VARPLACESTOTAL.size).append("@")
|
||||
cb.accept(result.toString())
|
||||
|
||||
// kirim VARSHALATTOTAL
|
||||
result.clear()
|
||||
result.append("VARSHALATTOTAL;")
|
||||
val VARSHALATTOTAL = mutableListOf<Soundbank>()
|
||||
db.soundDB.List
|
||||
.filter { it.Category.equals(Category.Shalat.name, true) }
|
||||
.distinctBy { it.TAG }
|
||||
.forEach {
|
||||
VARSHALATTOTAL.add(it)
|
||||
}
|
||||
result.append(VARSHALATTOTAL.size).append("@")
|
||||
cb.accept(result.toString())
|
||||
|
||||
// kirim VARSEQUENCETOTAL
|
||||
result.clear()
|
||||
result.append("VARSEQUENCETOTAL;")
|
||||
val VARSEQUENCETOTAL = mutableListOf<Soundbank>()
|
||||
db.soundDB.List
|
||||
.filter { it.Category.equals(Category.Sequence.name, true) }
|
||||
.distinctBy { it.TAG }
|
||||
.forEach {
|
||||
VARSEQUENCETOTAL.add(it)
|
||||
}
|
||||
result.append(VARSEQUENCETOTAL.size).append("@")
|
||||
cb.accept(result.toString())
|
||||
|
||||
// kirim VARREASONTOTAL
|
||||
result.clear()
|
||||
result.append("VARREASONTOTAL;")
|
||||
val VARREASONTOTAL = mutableListOf<Soundbank>()
|
||||
db.soundDB.List
|
||||
.filter { it.Category.equals(Category.Reason.name, true) }
|
||||
.distinctBy { it.TAG }
|
||||
.forEach {
|
||||
VARREASONTOTAL.add(it)
|
||||
}
|
||||
result.append(VARREASONTOTAL.size).append("@")
|
||||
cb.accept(result.toString())
|
||||
|
||||
// kirim VARPROCEDURETOTAL
|
||||
val VARPROCEDURETOTAL = mutableListOf<Soundbank>()
|
||||
result.clear()
|
||||
result.append("VARPROCEDURETOTAL;")
|
||||
db.soundDB.List
|
||||
.filter { it.Category.equals(Category.Procedure.name, true) }
|
||||
.distinctBy { it.TAG }
|
||||
.forEach {
|
||||
VARPROCEDURETOTAL.add(it)
|
||||
}
|
||||
result.append(VARPROCEDURETOTAL.size).append("@")
|
||||
cb.accept(result.toString())
|
||||
|
||||
// kirim VARGATETOTAL
|
||||
val VARGATETOTAL = mutableListOf<Soundbank>()
|
||||
result.clear()
|
||||
result.append("VARGATETOTAL;")
|
||||
db.soundDB.List
|
||||
.filter { it.Category.equals(Category.Gate.name, true) }
|
||||
.distinctBy { it.TAG }
|
||||
.forEach {
|
||||
VARGATETOTAL.add(it)
|
||||
}
|
||||
result.append(VARGATETOTAL.size).append("@")
|
||||
cb.accept(result.toString())
|
||||
|
||||
// kirim VARCOMPENSATIONTOTAL
|
||||
result.clear()
|
||||
result.append("VARCOMPENSATIONTOTAL;")
|
||||
val VARCOMPENSATIONTOTAL = mutableListOf<Soundbank>()
|
||||
db.soundDB.List
|
||||
.filter { it.Category.equals(Category.Compensation.name, true) }
|
||||
.distinctBy { it.TAG }
|
||||
.forEach {
|
||||
VARCOMPENSATIONTOTAL.add(it)
|
||||
}
|
||||
result.append(VARCOMPENSATIONTOTAL.size).append("@")
|
||||
cb.accept(result.toString())
|
||||
|
||||
// kirim VARGREETINGTOTAL
|
||||
result.clear()
|
||||
result.append("VARGREETINGTOTAL;")
|
||||
val VARGREETINGTOTAL = mutableListOf<Soundbank>()
|
||||
db.soundDB.List
|
||||
.filter { it.Category.equals(Category.Greeting.name, true) }
|
||||
.distinctBy { it.TAG }
|
||||
.forEach {
|
||||
VARGREETINGTOTAL.add(it)
|
||||
}
|
||||
result.append(VARGREETINGTOTAL.size).append("@")
|
||||
cb.accept(result.toString())
|
||||
|
||||
//Append MSG, for Android only Indonesia and English
|
||||
VARMESSAGES.groupBy { it.ANN_ID }.forEach { (ann_id, value) ->
|
||||
result.append("MSG;").append(ann_id)
|
||||
result.append(";")
|
||||
value.find { it.Language.equals(Language.INDONESIA.name, true) }?.let {result.append(it.Message_Detail)} ?: result.append("NA")
|
||||
result.append(";")
|
||||
value.find {it.Language.equals(Language.ENGLISH.name, true) }?.let {result.append(it.Message_Detail)} ?: result.append("NA")
|
||||
result.append("@")
|
||||
if (VARMESSAGES.isNotEmpty()) {
|
||||
result.clear()
|
||||
VARMESSAGES.forEachIndexed { index, msg ->
|
||||
|
||||
val ann_id = msg.ANN_ID
|
||||
val msg_indo = db.messageDB.List.find {
|
||||
it.ANN_ID == ann_id && it.Language.equals(
|
||||
Language.INDONESIA.name,
|
||||
true
|
||||
)
|
||||
}
|
||||
val msg_eng = db.messageDB.List.find {
|
||||
it.ANN_ID == ann_id && it.Language.equals(
|
||||
Language.ENGLISH.name,
|
||||
true
|
||||
)
|
||||
}
|
||||
val description = msg_indo?.Description ?: msg_eng?.Description ?: "UNKNOWN"
|
||||
result.append("MSG;$index;$ann_id;$description;")
|
||||
result.append(msg_indo?.Message_Detail ?:"").append(";")
|
||||
result.append(msg_eng?.Message_Detail ?:"").append("@")
|
||||
}
|
||||
cb.accept(result.toString())
|
||||
}
|
||||
|
||||
// append VARAP
|
||||
VARAPTOTAL.distinctBy { it.Description }.forEachIndexed { index, soundbank ->
|
||||
result.append("VARAP;").append(index).append(";").append(soundbank.TAG).append(";").append(soundbank.Description).append("@")
|
||||
if (VARAPTOTAL.isNotEmpty()) {
|
||||
result.clear()
|
||||
VARAPTOTAL.forEachIndexed { index, sb ->
|
||||
result.append("VARAP;$index;${sb.TAG};${sb.Description}@")
|
||||
}
|
||||
cb.accept(result.toString())
|
||||
}
|
||||
|
||||
// append VARCITY
|
||||
VARCITYTOTAL.distinctBy { it.Description }.forEachIndexed { index, soundbank ->
|
||||
result.append("VARCITY;").append(index).append(";").append(soundbank.TAG).append(";").append(soundbank.Description).append("@")
|
||||
if (VARCITYTOTAL.isNotEmpty()) {
|
||||
result.clear()
|
||||
VARCITYTOTAL.forEachIndexed { index, sb ->
|
||||
result.append("VARCITY;$index;${sb.TAG};${sb.Description}@")
|
||||
}
|
||||
cb.accept(result.toString())
|
||||
}
|
||||
|
||||
// append VARPLACES
|
||||
VARPLACESTOTAL.distinctBy { it.Description }.forEachIndexed { index, soundbank ->
|
||||
result.append("VARPLACES;").append(index).append(";").append(soundbank.TAG).append(";").append(soundbank.Description).append("@")
|
||||
if (VARPLACESTOTAL.isNotEmpty()) {
|
||||
result.clear()
|
||||
VARPLACESTOTAL.forEachIndexed { index, sb ->
|
||||
result.append("VARPLACES;$index;${sb.TAG};${sb.Description}@")
|
||||
}
|
||||
cb.accept(result.toString())
|
||||
}
|
||||
// append VARSHALAT
|
||||
VARSHALATTOTAL.distinctBy { it.Description }.forEachIndexed { index, soundbank ->
|
||||
result.append("VARSHALAT;").append(index).append(";").append(soundbank.TAG).append(";").append(soundbank.Description).append("@")
|
||||
if (VARSHALATTOTAL.isNotEmpty()) {
|
||||
result.clear()
|
||||
VARSHALATTOTAL.forEachIndexed { index, sb ->
|
||||
result.append("VARSHALAT;$index;${sb.TAG};${sb.Description}@")
|
||||
}
|
||||
cb.accept(result.toString())
|
||||
}
|
||||
|
||||
// append VARSEQUENCE
|
||||
VARSEQUENCETOTAL.distinctBy { it.Description }.forEachIndexed { index, soundbank ->
|
||||
result.append("VARSEQUENCE;").append(index).append(";").append(soundbank.TAG).append(";").append(soundbank.Description).append("@")
|
||||
if (VARSEQUENCETOTAL.isNotEmpty()) {
|
||||
result.clear()
|
||||
VARSEQUENCETOTAL.forEachIndexed { index, sb ->
|
||||
result.append("VARSEQUENCE;$index;${sb.TAG};${sb.Description}@")
|
||||
}
|
||||
cb.accept(result.toString())
|
||||
}
|
||||
|
||||
// append VARREASON
|
||||
VARREASONTOTAL.distinctBy { it.Description }.forEachIndexed { index, soundbank ->
|
||||
result.append("VARREASON;").append(index).append(";").append(soundbank.TAG).append(";").append(soundbank.Description).append("@")
|
||||
if (VARREASONTOTAL.isNotEmpty()) {
|
||||
result.clear()
|
||||
VARREASONTOTAL.forEachIndexed { index, sb ->
|
||||
result.append("VARREASON;$index;${sb.TAG};${sb.Description}@")
|
||||
}
|
||||
cb.accept(result.toString())
|
||||
}
|
||||
|
||||
// append VARPROCEDURE
|
||||
VARPROCEDURETOTAL.distinctBy { it.Description }.forEachIndexed { index, soundbank ->
|
||||
result.append("VARPROCEDURE;").append(index).append(";").append(soundbank.TAG).append(";").append(soundbank.Description).append("@")
|
||||
if (VARPROCEDURETOTAL.isNotEmpty()) {
|
||||
result.clear()
|
||||
VARPROCEDURETOTAL.forEachIndexed { index, sb ->
|
||||
result.append("VARPROCEDURE;$index;${sb.TAG};${sb.Description}@")
|
||||
}
|
||||
cb.accept(result.toString())
|
||||
}
|
||||
// send to sender
|
||||
cb.accept(result.toString())
|
||||
|
||||
// append VARGATE
|
||||
if (VARGATETOTAL.isNotEmpty()) {
|
||||
result.clear()
|
||||
VARGATETOTAL.forEachIndexed { index, sb ->
|
||||
result.append("VARGATE;$index;${sb.TAG};${sb.Description}@")
|
||||
}
|
||||
cb.accept(result.toString())
|
||||
}
|
||||
|
||||
// append VARCOMPENSATION
|
||||
if (VARCOMPENSATIONTOTAL.isNotEmpty()) {
|
||||
result.clear()
|
||||
VARCOMPENSATIONTOTAL.forEachIndexed { index, sb ->
|
||||
result.append("VARCOMPENSATION;$index;${sb.TAG};${sb.Description}@")
|
||||
}
|
||||
cb.accept(result.toString())
|
||||
}
|
||||
|
||||
// append VARGREETING
|
||||
if (VARGREETINGTOTAL.isNotEmpty()) {
|
||||
result.clear()
|
||||
VARGREETINGTOTAL.forEachIndexed { index, sb ->
|
||||
result.append("VARGREETING;$index;${sb.TAG};${sb.Description}@")
|
||||
}
|
||||
cb.accept(result.toString())
|
||||
}
|
||||
|
||||
logcb.accept("All variables sent to $key with username $username")
|
||||
return
|
||||
} else logcb.accept("STARTINITIALIZE failed from $key with username $username not found in userDB")
|
||||
@@ -387,8 +605,11 @@ class TCP_Android_Command_Server {
|
||||
"BROADCASTAND" -> {
|
||||
// semi auto dari android, masukin ke queue table
|
||||
val desc = parts.getOrElse(1) { "" }
|
||||
// language bisa lebih dari satu, dipisah dengan koma
|
||||
val lang = parts.getOrElse(2) { "" }.replace(",",";")
|
||||
// tags bisa lebih dari satu, dipisah dengan spasi
|
||||
val tags = parts.getOrElse(3) { "" }.replace(",",";")
|
||||
// zone bisa lebih dari satu, dipisah dengan koma
|
||||
val zone = parts.getOrElse(4) { "" }.replace(",",";")
|
||||
if (ValidString(desc)){
|
||||
if (ValidString(lang)){
|
||||
@@ -414,7 +635,7 @@ class TCP_Android_Command_Server {
|
||||
} else logcb.accept("Broadcsast request from Android $key username=${listUserLogin.find { it.ip==key }?.username ?: "UNKNOWN"} failed, empty tags")
|
||||
} else logcb.accept("Broadcast request from Android $key username=${listUserLogin.find { it.ip==key }?.username ?: "UNKNOWN"} failed, empty language")
|
||||
} else logcb.accept("Broadcast request from Android $key username=${listUserLogin.find { it.ip==key }?.username ?: "UNKNOWN"} failed, empty description")
|
||||
cb.accept("NG@")
|
||||
cb.accept("BROADCASTAND;NG@")
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user