Fixed calculating message size
This commit is contained in:
parent
b18edbf943
commit
361a4062cb
|
@ -35,8 +35,8 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
||||||
protected val utils: FinTsUtils = FinTsUtils()) {
|
protected val utils: FinTsUtils = FinTsUtils()) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val MessageHeaderLength = 30
|
const val MessageHeaderMinLength = 30
|
||||||
const val MessageEndingLength = 11
|
|
||||||
const val AddedSeparatorsLength = 3
|
const val AddedSeparatorsLength = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,13 +411,17 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
||||||
|
|
||||||
val formattedPayload = formatPayload(payloadSegments)
|
val formattedPayload = formatPayload(payloadSegments)
|
||||||
|
|
||||||
val messageSize = formattedPayload.length + MessageHeaderLength + MessageEndingLength + AddedSeparatorsLength
|
val ending = Nachrichtenabschluss(generator.getNextSegmentNumber(), dialogContext)
|
||||||
|
val formattedEnding = ending.format()
|
||||||
|
|
||||||
|
val minMessageSize = formattedPayload.length + MessageHeaderMinLength + formattedEnding.length + AddedSeparatorsLength
|
||||||
|
val headerWithMinMessageSize = Nachrichtenkopf(ISegmentNumberGenerator.FirstSegmentNumber, minMessageSize, dialogContext).format()
|
||||||
|
|
||||||
|
val messageSize = formattedPayload.length + headerWithMinMessageSize.length + formattedEnding.length + AddedSeparatorsLength
|
||||||
|
|
||||||
val header = Nachrichtenkopf(ISegmentNumberGenerator.FirstSegmentNumber, messageSize, dialogContext)
|
val header = Nachrichtenkopf(ISegmentNumberGenerator.FirstSegmentNumber, messageSize, dialogContext)
|
||||||
|
|
||||||
val ending = Nachrichtenabschluss(generator.getNextSegmentNumber(), dialogContext)
|
return listOf(header.format(), formattedPayload, formattedEnding)
|
||||||
|
|
||||||
return listOf(header.format(), formattedPayload, ending.format())
|
|
||||||
.joinToString(Separators.SegmentSeparator, postfix = Separators.SegmentSeparator)
|
.joinToString(Separators.SegmentSeparator, postfix = Separators.SegmentSeparator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue