本文整理汇总了Java中org.vertx.java.core.VertxFactory类的典型用法代码示例。如果您正苦于以下问题:Java VertxFactory类的具体用法?Java VertxFactory怎么用?Java VertxFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VertxFactory类属于org.vertx.java.core包,在下文中一共展示了VertxFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
public static void main(String[] args) {
// Configure the client.
String adCode3rd = "/?advideo/3.0/78.109/5798044/0//cc=2;vidAS=pre_roll;vidRT=VAST;vidRTV=2.0.1";
HttpClient httpClient = VertxFactory.newVertx().createHttpClient();
httpClient.setHost("adserver.adtech.de");
httpClient.get(adCode3rd, new Handler<HttpClientResponse>() {
@Override
public void handle(HttpClientResponse httpClientResponse) {
httpClientResponse.bodyHandler(new Handler<Buffer>() {
@Override
public void handle(Buffer buffer) {
System.out.println("Response (" + buffer.length() + "): ");
System.out.println(buffer.getString(0, buffer.length()));
}
});
}
});
Utils.sleep(10000);
}
示例2: EmulatorLaunchpad
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
/**
* Constructor.
*
* @param httpPort The HTTP port on which the emulator should run.
*/
public EmulatorLaunchpad(int httpPort) {
vertx = VertxFactory.newVertx();
// Static files
HttpServer httpServer = vertx.createHttpServer();
httpServer.requestHandler(new WebResourceHandler());
// Eventbus bridge
JsonObject bridgeConfig = new JsonObject().putString("prefix", EVENTBUS_ADDRESS);
JsonArray credentialsPermitAll = new JsonArray().add(new JsonObject());
vertx.createSockJSServer(httpServer).bridge(bridgeConfig, credentialsPermitAll, credentialsPermitAll);
vertx.eventBus().registerLocalHandler(EVENTBUS_SERVER_HANDLER_ID, eventBusHandler);
System.out.println("Launchpad emulator is ready on http://localhost:" + httpPort + "/");
httpServer.listen(httpPort);
}
示例3: checkAndCreateHttpServer
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
private HttpServer checkAndCreateHttpServer(String host, int port) {
if (isAddressAlreadyInUse(host, port)) {
System.err.println(host + ":" + port + " isAddressAlreadyInUse!");
System.exit(1);
return null;
}
try {
this.host = host;
this.port = port;
Vertx vertx = VertxFactory.newVertx();
return vertx.createHttpServer();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例4: connect
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
private void connect(final String ip, final String port) throws InterruptedException {
final CountDownLatch connected = new CountDownLatch(1);
final Vertx vertx = VertxFactory.newVertx();
client = vertx.
createHttpClient().
setHost(ip).
setPort(Integer.valueOf(port)).
connectWebsocket("/",
(ws) -> {
connected.countDown();
this.webSocket = ws;
ws.dataHandler(this::sendPixelDataToCanvas);
});
connected.await(5000, TimeUnit.MILLISECONDS);
context.send(BaseConfig.DRAWING_PERSPECTIVE, FragmentNavigation.FINISH);
}
示例5: startVertx
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
@Before
public void startVertx() {
if( vertx == null ) {
vertx = VertxFactory.newVertx();
}
}
示例6: VertxSink
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
/**
* Protected constructor.
*
* @param builder Instance of <code>Builder</code>.
*/
protected VertxSink(final Builder<?, ?> builder) {
super(builder);
_serverAddress = builder._serverAddress;
_hostnameResolver = builder._hostnameResolver;
_serverPort = builder._serverPort;
_vertx = VertxFactory.newVertx();
//Calling this just so the context gets created
if (_vertx instanceof DefaultVertx) {
final DefaultVertx vertx = (DefaultVertx) _vertx;
final DefaultContext context = vertx.getOrCreateContext();
vertx.setContext(context);
_context = context;
} else {
_context = null;
LOGGER.warn()
.setMessage("Vertx instance not a DefaultVertx as expected. Threading may be incorrect.")
.addData("sink", getName())
.log();
}
_client = _vertx.createNetClient()
.setReconnectAttempts(0)
.setConnectTimeout(5000)
.setTCPNoDelay(true)
.setTCPKeepAlive(true);
_socket = new AtomicReference<>();
_pendingData = EvictingQueue.create(builder._maxQueueSize);
_exponentialBackoffBase = builder._exponentialBackoffBase;
connectToServer();
consumeLoop();
}
示例7: startServer
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
@Override
protected void startServer(int port, Action<ServerWebSocket> websocketAction) {
server = VertxFactory.newVertx().createHttpServer();
final AsityWebSocketHandler websocketHandler = new AsityWebSocketHandler().onwebsocket
(websocketAction);
server.websocketHandler(new Handler<org.vertx.java.core.http.ServerWebSocket>() {
@Override
public void handle(org.vertx.java.core.http.ServerWebSocket socket) {
if (socket.path().equals(TEST_URI)) {
websocketHandler.handle(socket);
}
}
});
server.listen(port);
}
示例8: startServer
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
@Override
protected void startServer(int port, Action<ServerHttpExchange> requestAction) throws Exception {
server = VertxFactory.newVertx().createHttpServer();
RouteMatcher matcher = new RouteMatcher();
matcher.all(TEST_URI, new AsityRequestHandler().onhttp(requestAction));
server.requestHandler(matcher);
server.listen(port);
}
示例9: start
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
public void start(int port) {
vertx = VertxFactory.newVertx();
httpServer = vertx.createHttpServer();
httpServer.websocketHandler(new Handler<ServerWebSocket>() {
public void handle(final ServerWebSocket ws) {
if (ws.path().equals("/echo")) {
ws.frameHandler(new Handler<WebSocketFrame>() {
@Override
public void handle(WebSocketFrame webSocketFrame) {
if (webSocketFrame.isBinary()) {
Buffer buff = new Buffer(((WebSocketFrameInternal) webSocketFrame).getBinaryData());
ws.writeBinaryFrame(buff);
} else if (webSocketFrame.isText()) {
ws.writeTextFrame(webSocketFrame.textData());
}
}
});
} else {
ws.reject();
}
}
}).listen(port);
}
示例10: vertx
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
@Bean
public Vertx vertx() {
final String hostname = "127.0.0.1";
//final Integer port = 5454;
//try {
// This line will typically be return VertxFactory.newVertx(port, hostname)
return VertxFactory.newVertx(hostname);
//} catch (Exception e) {
// return VertxFactory.newVertx(hostname);
//}
}
示例11: startServer
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
@Override
protected void startServer() {
server = VertxFactory.newVertx().createHttpServer();
final VibeWebSocketHandler websocketHandler = new VibeWebSocketHandler().onwebsocket(performer.serverAction());
server.websocketHandler(new Handler<org.vertx.java.core.http.ServerWebSocket>() {
@Override
public void handle(org.vertx.java.core.http.ServerWebSocket socket) {
if (socket.path().equals("/test")) {
websocketHandler.handle(socket);
}
}
});
server.listen(port);
}
示例12: startServer
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
@Override
protected void startServer() {
server = VertxFactory.newVertx().createHttpServer();
RouteMatcher matcher = new RouteMatcher();
matcher.all("/test", new VibeRequestHandler().onhttp(performer.serverAction()));
server.requestHandler(matcher);
server.listen(port);
}
示例13: getClient
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
private HttpClient getClient() throws MalformedURLException, InterruptedException {
Vertx vertx = VertxFactory.newVertx();
HttpClient client = vertx.
createHttpClient().
setHost("localhost").
setPort(8080);
return client;
}
示例14: getClient
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
private HttpClient getClient(final Handler<WebSocket> handler, final String path) {
Vertx vertx = VertxFactory.newVertx();
HttpClient client = vertx.
createHttpClient().
setHost("localhost").
setPort(8080).
connectWebsocket(path, handler);
return client;
}
示例15: getClient
import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
private HttpClient getClient() {
Vertx vertx = VertxFactory.newVertx();
HttpClient client = vertx.
createHttpClient().
setHost("localhost").
setPort(8080);
return client;
}