本文整理汇总了Java中org.vertx.java.core.VertxFactory.newVertx方法的典型用法代码示例。如果您正苦于以下问题:Java VertxFactory.newVertx方法的具体用法?Java VertxFactory.newVertx怎么用?Java VertxFactory.newVertx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.vertx.java.core.VertxFactory
的用法示例。
在下文中一共展示了VertxFactory.newVertx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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);
}
示例4: startVertx
import org.vertx.java.core.VertxFactory; //导入方法依赖的package包/类
@Before
public void startVertx() {
if( vertx == null ) {
vertx = VertxFactory.newVertx();
}
}
示例5: 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();
}
示例6: 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);
}
示例7: 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);
//}
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: VertX
import org.vertx.java.core.VertxFactory; //导入方法依赖的package包/类
private VertX() {
final AppConfig config = AppConfig.getInstance();
vertx = VertxFactory.newVertx();
server = vertx.createHttpServer();
routeMatcher = new RouteMatcher();
server.requestHandler(routeMatcher);
server.listen(config.getInteger("webservice.port", DEFAULT_PORT));
}
示例12: VertX
import org.vertx.java.core.VertxFactory; //导入方法依赖的package包/类
private VertX() {
final AppConfig config = AppConfig.getInstance();
vertx = VertxFactory.newVertx();
server = vertx.createHttpServer();
routeMatcher = new RouteMatcher();
server.requestHandler(routeMatcher);
sockJsServer = vertx.createSockJSServer(server);
registerNomatchHandler();
server.listen(config.getInteger("webservice.webport", 8080));
LOG.debug("VertX initialized");
}
示例13: startVertx
import org.vertx.java.core.VertxFactory; //导入方法依赖的package包/类
@Before
public void startVertx() {
if (vertx == null) {
vertx = VertxFactory.newVertx();
}
}
示例14: WebServer
import org.vertx.java.core.VertxFactory; //导入方法依赖的package包/类
public WebServer(ArchiveFile archive) {
vertx = VertxFactory.newVertx();
quitLatch = new CountDownLatch(1);
this.archive = archive;
}
示例15: run
import org.vertx.java.core.VertxFactory; //导入方法依赖的package包/类
@Override
public void run() {
Vertx vertx = VertxFactory.newVertx();
vertx.createHttpServer().requestHandler(new MyHandler()).listen(5556);
System.out.println("Server running at http://127.0.0.1:5556/");
}