Closed ramukima closed 8 years ago
package test; import io.vertx.core.Handler; import io.vertx.core.Vertx; import io.vertx.core.json.JsonObject; import io.vertx.ext.bridge.BridgeOptions; import io.vertx.ext.bridge.PermittedOptions; import io.vertx.ext.eventbus.bridge.tcp.TcpEventBusBridge; public class BridgeTest { public static void main(String[] args) { Vertx vertx = Vertx.vertx(); TcpEventBusBridge bridge = TcpEventBusBridge.create( vertx, new BridgeOptions() .addOutboundPermitted(new PermittedOptions().setAddress("out"))); bridge.listen(7000, res -> vertx.setPeriodic(2*1000, new Handler<Long>() { @Override public void handle(Long timer) { vertx.eventBus().send("out", new JsonObject().put("now", System.currentTimeMillis())); } })); } }
var EventBus = require('../lib/tcp-vertx-eventbus'); var eb = new EventBus('localhost', 7000); eb.onerror = function (err) { console.error(err); }; eb.onopen = function () { // send a echo message eb.registerHandler("out", function (err, msg) { console.log("message:" + JSON.stringify(msg)); }); };
bash-3.2$ node test/app.js message:{"type":"message","address":"out","headers":{},"body":{"now":1453190899736}} message:{"type":"message","address":"out","headers":{},"body":{"now":1453190899736}} message:{"type":"message","address":"out","headers":{},"body":{"now":1453190899736}} message:{"type":"message","address":"out","headers":{},"body":{"now":1453190899736}} message:{"type":"message","address":"out","headers":{},"body":{"now":1453190899736}}
Notice the value of 'now' in the message received by the client.
Verified. Works now, thanks for fixing this.
Server
Client
Result
Notice the value of 'now' in the message received by the client.