Search in sources :

Example 16 with SockJSHandler

use of io.vertx.ext.web.handler.sockjs.SockJSHandler in project vertx-web by vert-x3.

the class WebExamples method example43.

public void example43(Vertx vertx) {
    Router router = Router.router(vertx);
    SockJSHandlerOptions options = new SockJSHandlerOptions().setHeartbeatInterval(2000);
    SockJSHandler sockJSHandler = SockJSHandler.create(vertx, options);
}
Also used : SockJSHandlerOptions(io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions) SockJSHandler(io.vertx.ext.web.handler.sockjs.SockJSHandler)

Example 17 with SockJSHandler

use of io.vertx.ext.web.handler.sockjs.SockJSHandler in project vertx-web by vert-x3.

the class WebExamples method example49.

public void example49(Vertx vertx) {
    Router router = Router.router(vertx);
    // Let through any messages sent to 'demo.orderMgr' from the client
    PermittedOptions inboundPermitted = new PermittedOptions().setAddress("demo.someService");
    SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
    SockJSBridgeOptions options = new SockJSBridgeOptions().addInboundPermitted(inboundPermitted);
    // mount the bridge on the router
    router.mountSubRouter("/eventbus", sockJSHandler.bridge(options, be -> {
        if (be.type() == BridgeEventType.PUBLISH || be.type() == BridgeEventType.RECEIVE) {
            if (be.getRawMessage().getString("body").equals("armadillos")) {
                // Reject it
                be.complete(false);
                return;
            }
        }
        be.complete(true);
    }));
}
Also used : LocalSessionStore(io.vertx.ext.web.sstore.LocalSessionStore) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) OAuth2Options(io.vertx.ext.auth.oauth2.OAuth2Options) GithubAuth(io.vertx.ext.auth.oauth2.providers.GithubAuth) RoutingContextInternal(io.vertx.ext.web.impl.RoutingContextInternal) io.vertx.ext.auth.webauthn(io.vertx.ext.auth.webauthn) Function(java.util.function.Function) EventBus(io.vertx.core.eventbus.EventBus) RoleBasedAuthorization(io.vertx.ext.auth.authorization.RoleBasedAuthorization) SockJSHandler(io.vertx.ext.web.handler.sockjs.SockJSHandler) BridgeEventType(io.vertx.ext.bridge.BridgeEventType) JsonObject(io.vertx.core.json.JsonObject) SockJSBridgeOptions(io.vertx.ext.web.handler.sockjs.SockJSBridgeOptions) AuthorizationProvider(io.vertx.ext.auth.authorization.AuthorizationProvider) SockJSHandlerOptions(io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions) ClusteredSessionStore(io.vertx.ext.web.sstore.ClusteredSessionStore) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) Set(java.util.Set) AuthenticationProvider(io.vertx.ext.auth.authentication.AuthenticationProvider) JWTAuthOptions(io.vertx.ext.auth.jwt.JWTAuthOptions) OAuth2FlowType(io.vertx.ext.auth.oauth2.OAuth2FlowType) Future(io.vertx.core.Future) io.vertx.core.http(io.vertx.core.http) KeyStoreOptions(io.vertx.ext.auth.KeyStoreOptions) JsonArray(io.vertx.core.json.JsonArray) JWTOptions(io.vertx.ext.auth.JWTOptions) io.vertx.ext.web(io.vertx.ext.web) io.vertx.ext.web.handler(io.vertx.ext.web.handler) List(java.util.List) User(io.vertx.ext.auth.User) Buffer(io.vertx.core.buffer.Buffer) SessionStore(io.vertx.ext.web.sstore.SessionStore) TotpAuth(io.vertx.ext.auth.otp.totp.TotpAuth) DataObject(io.vertx.codegen.annotations.DataObject) PermissionBasedAuthorization(io.vertx.ext.auth.authorization.PermissionBasedAuthorization) OAuth2Auth(io.vertx.ext.auth.oauth2.OAuth2Auth) Handler(io.vertx.core.Handler) PermittedOptions(io.vertx.ext.bridge.PermittedOptions) JWTAuth(io.vertx.ext.auth.jwt.JWTAuth) SockJSBridgeOptions(io.vertx.ext.web.handler.sockjs.SockJSBridgeOptions) PermittedOptions(io.vertx.ext.bridge.PermittedOptions) SockJSHandler(io.vertx.ext.web.handler.sockjs.SockJSHandler)

Example 18 with SockJSHandler

use of io.vertx.ext.web.handler.sockjs.SockJSHandler in project vertx-web by vert-x3.

the class WebExamples method example48_1.

public void example48_1(Vertx vertx) {
    Router router = Router.router(vertx);
    // Let through any messages sent to 'demo.orderService' from the client
    PermittedOptions inboundPermitted = new PermittedOptions().setAddress("demo.orderService");
    SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
    SockJSBridgeOptions options = new SockJSBridgeOptions().addInboundPermitted(inboundPermitted);
    // mount the bridge on the router
    router.mountSubRouter("/eventbus", sockJSHandler.bridge(options, be -> {
        if (be.type() == BridgeEventType.PUBLISH || be.type() == BridgeEventType.SEND) {
            // Add some headers
            JsonObject headers = new JsonObject().put("header1", "val").put("header2", "val2");
            JsonObject rawMessage = be.getRawMessage();
            rawMessage.put("headers", headers);
            be.setRawMessage(rawMessage);
        }
        be.complete(true);
    }));
}
Also used : LocalSessionStore(io.vertx.ext.web.sstore.LocalSessionStore) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) OAuth2Options(io.vertx.ext.auth.oauth2.OAuth2Options) GithubAuth(io.vertx.ext.auth.oauth2.providers.GithubAuth) RoutingContextInternal(io.vertx.ext.web.impl.RoutingContextInternal) io.vertx.ext.auth.webauthn(io.vertx.ext.auth.webauthn) Function(java.util.function.Function) EventBus(io.vertx.core.eventbus.EventBus) RoleBasedAuthorization(io.vertx.ext.auth.authorization.RoleBasedAuthorization) SockJSHandler(io.vertx.ext.web.handler.sockjs.SockJSHandler) BridgeEventType(io.vertx.ext.bridge.BridgeEventType) JsonObject(io.vertx.core.json.JsonObject) SockJSBridgeOptions(io.vertx.ext.web.handler.sockjs.SockJSBridgeOptions) AuthorizationProvider(io.vertx.ext.auth.authorization.AuthorizationProvider) SockJSHandlerOptions(io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions) ClusteredSessionStore(io.vertx.ext.web.sstore.ClusteredSessionStore) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) Set(java.util.Set) AuthenticationProvider(io.vertx.ext.auth.authentication.AuthenticationProvider) JWTAuthOptions(io.vertx.ext.auth.jwt.JWTAuthOptions) OAuth2FlowType(io.vertx.ext.auth.oauth2.OAuth2FlowType) Future(io.vertx.core.Future) io.vertx.core.http(io.vertx.core.http) KeyStoreOptions(io.vertx.ext.auth.KeyStoreOptions) JsonArray(io.vertx.core.json.JsonArray) JWTOptions(io.vertx.ext.auth.JWTOptions) io.vertx.ext.web(io.vertx.ext.web) io.vertx.ext.web.handler(io.vertx.ext.web.handler) List(java.util.List) User(io.vertx.ext.auth.User) Buffer(io.vertx.core.buffer.Buffer) SessionStore(io.vertx.ext.web.sstore.SessionStore) TotpAuth(io.vertx.ext.auth.otp.totp.TotpAuth) DataObject(io.vertx.codegen.annotations.DataObject) PermissionBasedAuthorization(io.vertx.ext.auth.authorization.PermissionBasedAuthorization) OAuth2Auth(io.vertx.ext.auth.oauth2.OAuth2Auth) Handler(io.vertx.core.Handler) PermittedOptions(io.vertx.ext.bridge.PermittedOptions) JWTAuth(io.vertx.ext.auth.jwt.JWTAuth) SockJSBridgeOptions(io.vertx.ext.web.handler.sockjs.SockJSBridgeOptions) JsonObject(io.vertx.core.json.JsonObject) PermittedOptions(io.vertx.ext.bridge.PermittedOptions) SockJSHandler(io.vertx.ext.web.handler.sockjs.SockJSHandler)

Aggregations

SockJSHandler (io.vertx.ext.web.handler.sockjs.SockJSHandler)18 JsonObject (io.vertx.core.json.JsonObject)11 EventBus (io.vertx.core.eventbus.EventBus)10 BridgeOptions (io.vertx.ext.web.handler.sockjs.BridgeOptions)9 PermittedOptions (io.vertx.ext.bridge.PermittedOptions)8 Router (io.vertx.ext.web.Router)8 PermittedOptions (io.vertx.ext.web.handler.sockjs.PermittedOptions)8 SockJSBridgeOptions (io.vertx.ext.web.handler.sockjs.SockJSBridgeOptions)8 SockJSHandlerOptions (io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions)7 DataObject (io.vertx.codegen.annotations.DataObject)5 Future (io.vertx.core.Future)5 Handler (io.vertx.core.Handler)5 Vertx (io.vertx.core.Vertx)5 VertxOptions (io.vertx.core.VertxOptions)5 Buffer (io.vertx.core.buffer.Buffer)5 io.vertx.core.http (io.vertx.core.http)5 JsonArray (io.vertx.core.json.JsonArray)5 JWTOptions (io.vertx.ext.auth.JWTOptions)5 KeyStoreOptions (io.vertx.ext.auth.KeyStoreOptions)5 User (io.vertx.ext.auth.User)5