use of io.vertx.ext.web.handler.sockjs.PermittedOptions in project vertx-examples by vert-x3.
the class Server method start.
@Override
public void start() throws Exception {
Router router = Router.router(vertx);
// Allow events for the designated addresses in/out of the event bus bridge
BridgeOptions opts = new BridgeOptions().addInboundPermitted(new PermittedOptions().setAddress("com.example:cmd:poke-server")).addOutboundPermitted(new PermittedOptions().setAddress("com.example:stat:server-info"));
// Create the event bus bridge and add it to the router.
SockJSHandler ebHandler = SockJSHandler.create(vertx).bridge(opts);
router.route("/eventbus/*").handler(ebHandler);
// Create a router endpoint for the static content.
router.route().handler(StaticHandler.create());
// Start the web server and tell it to use the router to handle requests.
vertx.createHttpServer().requestHandler(router::accept).listen(8080);
EventBus eb = vertx.eventBus();
vertx.setPeriodic(1000l, t -> {
// Create a timestamp string
String timestamp = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(Date.from(Instant.now()));
eb.send("com.example:stat:server-info", new JsonObject().put("systemTime", timestamp));
});
}
use of io.vertx.ext.web.handler.sockjs.PermittedOptions in project vertx-openshift-it by cescoffier.
the class GreetingServiceVerticle method getSockJsHandler.
private Handler<RoutingContext> getSockJsHandler() {
SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
BridgeOptions options = new BridgeOptions();
options.addInboundPermitted(new PermittedOptions().setAddress("circuit-breaker"));
options.addOutboundPermitted(new PermittedOptions().setAddress("circuit-breaker"));
return sockJSHandler.bridge(options);
}
Aggregations