Skip to content

Commit 85549bb

Browse files
committed
allow raw values
1 parent 8cb5b5e commit 85549bb

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/jvmMain/kotlin/spp/protocol/extend/TCPServiceFrameParser.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package spp.protocol.extend
22

3-
import spp.protocol.error.*
4-
import spp.protocol.error.LiveInstrumentException.ErrorType
53
import io.vertx.core.AsyncResult
64
import io.vertx.core.Handler
75
import io.vertx.core.Vertx
@@ -12,6 +10,8 @@ import io.vertx.core.json.JsonObject
1210
import io.vertx.core.net.NetSocket
1311
import io.vertx.ext.bridge.BridgeEventType
1412
import io.vertx.ext.eventbus.bridge.tcp.impl.protocol.FrameHelper
13+
import spp.protocol.error.*
14+
import spp.protocol.error.LiveInstrumentException.ErrorType
1515

1616
class TCPServiceFrameParser(val vertx: Vertx, val socket: NetSocket) : Handler<AsyncResult<JsonObject>> {
1717

@@ -56,11 +56,16 @@ class TCPServiceFrameParser(val vertx: Vertx, val socket: NetSocket) : Handler<A
5656
}
5757
}
5858
} else {
59-
val body = frame.getJsonObject("body")
60-
if (body.fieldNames().size == 1 && body.containsKey("value")) {
61-
//todo: understand why can't just re-send body like below
62-
vertx.eventBus()
63-
.send("local." + frame.getString("address"), body.getValue("value"))
59+
val body = frame.getValue("body")
60+
if (body is JsonObject) {
61+
if (body.fieldNames().size == 1 && body.containsKey("value")) {
62+
//todo: understand why can't just re-send body like below
63+
vertx.eventBus()
64+
.send("local." + frame.getString("address"), body.getValue("value"))
65+
} else {
66+
vertx.eventBus()
67+
.send("local." + frame.getString("address"), body)
68+
}
6469
} else {
6570
vertx.eventBus()
6671
.send("local." + frame.getString("address"), body)

0 commit comments

Comments
 (0)