summaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
authorEdoardo La Greca2025-07-29 00:07:13 +0200
committerEdoardo La Greca2025-07-29 00:07:13 +0200
commit4267371dfc17faf5b65192e0fba1a511b49993b5 (patch)
tree40d21619d91d7d4e8c5b7aea80e163b762b0bbf2 /src/main/kotlin
parent158d7282ef386531bb1b6e0a7b3dd1c1fa552548 (diff)
fix tags in several methods
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/NinePConnection.kt11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main/kotlin/NinePConnection.kt b/src/main/kotlin/NinePConnection.kt
index 5a09e8b..b23fd1f 100644
--- a/src/main/kotlin/NinePConnection.kt
+++ b/src/main/kotlin/NinePConnection.kt
@@ -73,11 +73,11 @@ class NinePConnection(netPackTrans: NetworkPacketTransporter) : NinePTranslator
* @return A triple in which the first element is the message size in bytes, the second is the message type as a
* [NinePMessageType] constant, and the third element is the message tag.
*/
- private fun readSizeTypeTag(): Triple<UInt, NinePMessageType, UInt> {
+ private fun readSizeTypeTag(): Triple<UInt, NinePMessageType, UShort> {
return Triple(
readInteger(4).toInt().toUInt(),
NinePMessageType.fromByte(readInteger(1).toByte()),
- readInteger(2).toInt().toUInt()
+ readInteger(2).toInt().toUShort()
)
}
@@ -89,10 +89,10 @@ class NinePConnection(netPackTrans: NetworkPacketTransporter) : NinePTranslator
* @param tag The tag to wait for.
* @return A pair of (1) the size and (2) the type of the message that matches the given tag.
*/
- private fun waitForTag(tag: UInt): Pair<UInt, NinePMessageType> {
+ private fun waitForTag(tag: UShort): Pair<UInt, NinePMessageType> {
var s = 0u
var ty: NinePMessageType? = null
- var ta = 0u
+ var ta: UShort = 0u
var found = false
while (!found) {
val stt = readSizeTypeTag()
@@ -179,6 +179,7 @@ class NinePConnection(netPackTrans: NetworkPacketTransporter) : NinePTranslator
val totalSize = 4 + 1 + 2 + insecInts.sumOf { fieldValuesInt[it]!!.size } + insecStrs.sumOf { 2 + fieldValuesStr[it]!!.length }
writeMessageSizeType(totalSize, type)
+ writeInteger(SizedMessageField(2, tag.toInt().toBigInteger()))
for (field in fieldNames) {
if (field in insecInts) {
writeInteger(fieldValuesInt[field]!!)
@@ -197,7 +198,7 @@ class NinePConnection(netPackTrans: NetworkPacketTransporter) : NinePTranslator
"version" to version
)
)
- val se = waitForTag(tag.value.toInt().toUInt())
+ val se = waitForTag(this.NOTAG)
if (se.second == NinePMessageType.RERROR) {
val error = readError()
return error.second