1
1
package spp.protocol.extend
2
2
3
- import spp.protocol.error.*
4
- import spp.protocol.error.LiveInstrumentException.ErrorType
5
3
import io.vertx.core.AsyncResult
6
4
import io.vertx.core.Handler
7
5
import io.vertx.core.Vertx
@@ -12,6 +10,8 @@ import io.vertx.core.json.JsonObject
12
10
import io.vertx.core.net.NetSocket
13
11
import io.vertx.ext.bridge.BridgeEventType
14
12
import io.vertx.ext.eventbus.bridge.tcp.impl.protocol.FrameHelper
13
+ import spp.protocol.error.*
14
+ import spp.protocol.error.LiveInstrumentException.ErrorType
15
15
16
16
class TCPServiceFrameParser (val vertx : Vertx , val socket : NetSocket ) : Handler<AsyncResult<JsonObject>> {
17
17
@@ -56,11 +56,16 @@ class TCPServiceFrameParser(val vertx: Vertx, val socket: NetSocket) : Handler<A
56
56
}
57
57
}
58
58
} 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
+ }
64
69
} else {
65
70
vertx.eventBus()
66
71
.send(" local." + frame.getString(" address" ), body)
0 commit comments