当前位置: 首页>>代码示例>>Java>>正文


Java PermittedOptions类代码示例

本文整理汇总了Java中io.vertx.ext.bridge.PermittedOptions的典型用法代码示例。如果您正苦于以下问题:Java PermittedOptions类的具体用法?Java PermittedOptions怎么用?Java PermittedOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PermittedOptions类属于io.vertx.ext.bridge包,在下文中一共展示了PermittedOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addRoutes

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
@Override
public SFDCRouterExtension addRoutes(final Router router) {
	// Socket handler
	final SockJSHandlerOptions options = new SockJSHandlerOptions().setHeartbeatInterval(2000);
	final SockJSHandler sockJSHandler = SockJSHandler.create(this.vertx, options);

	final BridgeOptions bo = new BridgeOptions()
			.addOutboundPermitted(new PermittedOptions().setAddress(this.getWebSocketName()));

	sockJSHandler.bridge(bo, event -> {
		this.logger.info("A websocket event occurred: " + event.type() + "; " + event.getRawMessage());
		event.complete(true);
	});

	final String someURL = this.getConsumerConfig().getUrl();
	this.logger.info("Router listening on " + someURL + " for " + this.getWebSocketName());
	router.route(someURL).handler(sockJSHandler);
	return this;
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:20,代码来源:WebSocketConsumer.java

示例2: example1

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
public void example1(Vertx vertx) {

    TcpEventBusBridge bridge = TcpEventBusBridge.create(
        vertx,
        new BridgeOptions()
            .addInboundPermitted(new PermittedOptions().setAddress("in"))
            .addOutboundPermitted(new PermittedOptions().setAddress("out")));

    bridge.listen(7000, res -> {
      if (res.succeeded()) {
        // succeed...
      } else {
        // fail...
      }
    });

  }
 
开发者ID:vert-x3,项目名称:vertx-tcp-eventbus-bridge,代码行数:18,代码来源:TCPBridgeExamples.java

示例3: before

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
@Before
public void before(TestContext context) {
  vertx = Vertx.vertx();
  final Async async = context.async();

  vertx.eventBus().consumer("hello", (Message<JsonObject> msg) -> msg.reply(new JsonObject().put("value", "Hello " + msg.body().getString("value"))));

  TcpEventBusBridge bridge = TcpEventBusBridge.create(
          vertx,
          new BridgeOptions()
                  .addInboundPermitted(new PermittedOptions())
                  .addOutboundPermitted(new PermittedOptions()));

  bridge.listen(7000, res -> {
    context.assertTrue(res.succeeded());
    async.complete();
  });
}
 
开发者ID:vert-x3,项目名称:vertx-tcp-eventbus-bridge,代码行数:19,代码来源:TcpEventBusBridgeInteropTest.java

示例4: testThatEventBusMessagesAreOnlyTransferredToOneStompClientsInP2P

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
@Test
public void testThatEventBusMessagesAreOnlyTransferredToOneStompClientsInP2P() throws InterruptedException {
  List<Frame> frames = new CopyOnWriteArrayList<>();
  server.stompHandler().bridge(new BridgeOptions()
          .addOutboundPermitted(new PermittedOptions().setAddress("/toStomp"))
          .setPointToPoint(true)
  );

  clients.add(StompClient.create(vertx).connect(ar -> {
    final StompClientConnection connection = ar.result();
    connection.subscribe("/toStomp", frames::add,
        f -> {
          clients.add(StompClient.create(vertx).connect(ar2 -> {
            final StompClientConnection connection2 = ar2.result();
            connection2.subscribe("/toStomp", frames::add, receipt -> {
              vertx.eventBus().publish("/toStomp", "Hello from Vert.x", new DeliveryOptions().addHeader("foo", "bar"));
            });
          }));
        });
  }));

  Thread.sleep(500);
  assertThat(frames).hasSize(1);
}
 
开发者ID:vert-x3,项目名称:vertx-stomp,代码行数:25,代码来源:EventBusBridgeTest.java

示例5: testThatEventBusConsumerCanReplyToStompMessages

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
@Test
public void testThatEventBusConsumerCanReplyToStompMessages() {
  server.stompHandler().bridge(new BridgeOptions()
          .addOutboundPermitted(new PermittedOptions().setAddress("/replyTo"))
          .addInboundPermitted(new PermittedOptions().setAddress("/request"))
          .setPointToPoint(true)
  );

  AtomicReference<Frame> response = new AtomicReference<>();

  consumers.add(vertx.eventBus().consumer("/request", msg -> {
    msg.reply("pong");
  }));

  clients.add(StompClient.create(vertx).connect(ar -> {
    final StompClientConnection connection = ar.result();
    connection.subscribe("/replyTo", response::set, r1 -> {
      connection.send("/request", Headers.create("reply-address", "/replyTo"), Buffer.buffer("ping"));
    });
  }));

  Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> response.get() != null);
}
 
开发者ID:vert-x3,项目名称:vertx-stomp,代码行数:24,代码来源:EventBusBridgeTest.java

示例6: setUp

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
@Before
public void setUp() {
  vertx = Vertx.vertx();
  AsyncLock<HttpServer> httpLock = new AsyncLock<>();
  AsyncLock<StompServer> stompLock = new AsyncLock<>();

  vertx = Vertx.vertx();

  server = StompServer.create(vertx, new StompServerOptions().setWebsocketBridge(true))
      .handler(StompServerHandler.create(vertx)
       .bridge(new BridgeOptions()
        .addInboundPermitted(new PermittedOptions().setAddressRegex(".*"))
        .addOutboundPermitted(new PermittedOptions().setAddressRegex(".*")))
      )
      .listen(stompLock.handler());
  stompLock.waitForSuccess();

  HttpServerOptions httpOptions = new HttpServerOptions()
    .setMaxWebsocketFrameSize(MAX_WEBSOCKET_FRAME_SIZE)
    .setMaxWebsocketMessageSize(2048);

  http = vertx.createHttpServer(httpOptions).websocketHandler(server.webSocketHandler()).listen(8080, httpLock.handler());
  httpLock.waitForSuccess();
}
 
开发者ID:vert-x3,项目名称:vertx-stomp,代码行数:25,代码来源:WebSocketBridgeTest.java

示例7: example48_1

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
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);
    BridgeOptions options = new BridgeOptions().addInboundPermitted(inboundPermitted);

    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);
    });

    router.route("/eventbus/*").handler(sockJSHandler);


  }
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:26,代码来源:WebExamples.java

示例8: example49

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
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);
    BridgeOptions options = new BridgeOptions().addInboundPermitted(inboundPermitted);

    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);
    });

    router.route("/eventbus/*").handler(sockJSHandler);


  }
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:26,代码来源:WebExamples.java

示例9: handleSocketIdle

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
public void handleSocketIdle(Vertx vertx, PermittedOptions inboundPermitted) {
  Router router = Router.router(vertx);

  // Initialize SockJS handler
  SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
  BridgeOptions options = new BridgeOptions().addInboundPermitted(inboundPermitted).setPingTimeout(5000);

  sockJSHandler.bridge(options, be -> {
    if (be.type() == BridgeEventType.SOCKET_IDLE) {
      // Do some custom handling...
    }

    be.complete(true);
  });

  router.route("/eventbus/*").handler(sockJSHandler);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:18,代码来源:WebExamples.java

示例10: testPermittedOptionsJson

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
@Test
public void testPermittedOptionsJson() {
  String address = TestUtils.randomAlphaString(10);
  String addressRegex = TestUtils.randomAlphaString(10);
  String requiredAuthority = TestUtils.randomAlphaString(10);
  JsonObject match = new JsonObject().put(TestUtils.randomAlphaString(10), TestUtils.randomAlphaString(10));
  JsonObject json = new JsonObject().
    put("address", address).
    put("addressRegex", addressRegex).
    put("requiredAuthority", requiredAuthority).
    put("match", match);
  PermittedOptions options = new PermittedOptions(json);
  assertEquals(address, options.getAddress());
  assertEquals(addressRegex, options.getAddressRegex());
  assertEquals(requiredAuthority, options.getRequiredAuthority());
  assertEquals(match, options.getMatch());
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:18,代码来源:EventbusBridgeTest.java

示例11: start

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
@Override
public void start() throws Exception {
    Router router = Router.router(vertx);
    
    BridgeOptions options = new BridgeOptions();
    options.setOutboundPermitted(Collections.singletonList(new PermittedOptions()
        .setAddress("average")));
    router.route("/eventbus/*").handler(SockJSHandler.create(vertx).bridge(options));
    
    router.route().handler(StaticHandler.create().setCachingEnabled(false));

    vertx.createHttpServer()
        .requestHandler(router::accept)
        .listen(8080);
}
 
开发者ID:cescoffier,项目名称:various-vertx-demos,代码行数:16,代码来源:WebVerticle.java

示例12: Broadcaster

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
public Broadcaster(Vertx vertx, RoomHandler roomHandler) {
    this.vertx = vertx;
    this.sockJSHandler = SockJSHandler.create(vertx);
    sockJSHandler.bridge(new BridgeOptions().addOutboundPermitted(
            new PermittedOptions().setAddressRegex("speechdrop\\.room\\..+")
    ), be -> {
        if (be.type() == BridgeEventType.REGISTER) {
            String address = be.getRawMessage().getString("address");
            String roomId = getRoomId(address);
            if (roomId != null && roomHandler.roomExists(roomId)) {
                roomHandler.getRoom(roomId).getIndex().setHandler(ar -> {
                    // Copies envelope structure from EventBusBridgeImpl##deliverMessage
                    be.socket().write(Buffer.buffer(new JsonObject()
                            .put("type", "rec")
                            .put("address", address)
                            .put("body", ar.result())
                            .encode()
                    ));
                });
            } else {
                be.complete(false);
                return;
            }
        }
        be.complete(true);
    });
}
 
开发者ID:yunyu,项目名称:SpeechDrop,代码行数:28,代码来源:Broadcaster.java

示例13: addEventBusHandler

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
private void addEventBusHandler() {
	SockJSHandler handler = null;
	if (localRouter != null) {
		SockJSHandlerOptions sockJSoptions = new SockJSHandlerOptions().setHeartbeatInterval(2000);
		handler = SockJSHandler.create(Mesh.vertx(), sockJSoptions);
		BridgeOptions bridgeOptions = new BridgeOptions();
		for (String addr : Events.publicEvents()) {
			bridgeOptions.addInboundPermitted(new PermittedOptions().setAddress(addr));
			bridgeOptions.addOutboundPermitted(new PermittedOptions().setAddress(addr));
		}
		handler.bridge(bridgeOptions, event -> {
			if (log.isDebugEnabled()) {
				if (event.type() == BridgeEventType.SOCKET_CREATED) {
					log.debug("A websocket was created");
				}
			}
			// Only grant access to authenticated users
			User user = event.socket().webUser();
			boolean isAuthenticated = user != null;
			event.complete(isAuthenticated);
		});
	}

	secureAll();
	EndpointRoute endpoint = createEndpoint();
	endpoint.setRAMLPath("/");
	endpoint.description("This endpoint provides a sockjs complient websocket which can be used to interface with the vert.x eventbus.");
	endpoint.path("/*").handler(handler);

}
 
开发者ID:gentics,项目名称:mesh,代码行数:31,代码来源:EventbusEndpoint.java

示例14: checkMatches

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
private boolean checkMatches(boolean inbound, String address, Map<String, Message<JsonObject>> replies) {
  // special case, when dealing with replies the addresses are not in the inbound/outbound list but on
  // the replies registry
  if (replies != null && inbound && replies.containsKey(address)) {
    return true;
  }

  List<PermittedOptions> matches = inbound ? options.getInboundPermitteds() : options.getOutboundPermitteds();

  for (PermittedOptions matchHolder : matches) {
    String matchAddress = matchHolder.getAddress();
    String matchRegex;
    if (matchAddress == null) {
      matchRegex = matchHolder.getAddressRegex();
    } else {
      matchRegex = null;
    }

    boolean addressOK;
    if (matchAddress == null) {
      addressOK = matchRegex == null || regexMatches(matchRegex, address);
    } else {
      addressOK = matchAddress.equals(address);
    }

    if (addressOK) {
      return true;
    }
  }

  return false;
}
 
开发者ID:vert-x3,项目名称:vertx-tcp-eventbus-bridge,代码行数:33,代码来源:TcpEventBusBridgeImpl.java

示例15: testInheritance

import io.vertx.ext.bridge.PermittedOptions; //导入依赖的package包/类
@Test
public void testInheritance() {
  MyBridgeOptions options = new MyBridgeOptions();
  options.setFlag(true);
  options.addInboundPermitted(new PermittedOptions().setAddress("foo"));

  JsonObject json = options.toJson();

  MyBridgeOptions options2 = new MyBridgeOptions(json);
  assertThat(options2.isFlag()).isTrue();
  assertThat(options2.getInboundPermitteds().get(0).getAddress()).isEqualTo("foo");
}
 
开发者ID:vert-x3,项目名称:vertx-bridge-common,代码行数:13,代码来源:InheritanceTest.java


注:本文中的io.vertx.ext.bridge.PermittedOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。