本文整理了Java中io.reactivex.netty.RxNetty
类的一些代码示例,展示了RxNetty
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RxNetty
类的具体详情如下:
包路径:io.reactivex.netty.RxNetty
类名称:RxNetty
暂无
代码示例来源:origin: ReactiveX/RxNetty
public static EventLoopGroup defaultEventloopGroup() {
return RxNetty.getRxEventLoopProvider().globalClientEventLoop(true);
}
代码示例来源:origin: ReactiveX/RxNetty
public static Class<? extends Channel> defaultSocketChannelClass() {
return RxNetty.isUsingNativeTransport() ? EpollSocketChannel.class : NioSocketChannel.class;
}
代码示例来源:origin: io.reactivex/rxnetty
public static void main(String[] args) {
RxNetty.createHttpServer(8888, new RequestHandler<ByteBuf, ByteBuf>() {
@Override
public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
throw new NullPointerException("doomsday");
}
}).startAndWait();
}
}
代码示例来源:origin: com.netflix.rxnetty/rx-netty
public static <I, O> RxServer<I, O> createTcpServer(final int port, PipelineConfigurator<I, O> pipelineConfigurator,
ConnectionHandler<I, O> connectionHandler) {
return newTcpServerBuilder(port, connectionHandler).pipelineConfigurator(pipelineConfigurator).build();
}
代码示例来源:origin: com.netflix.rxnetty/rx-netty
public static HttpClient<ByteBuf, ByteBuf> createHttpClient(String host, int port) {
return RxNetty.<ByteBuf, ByteBuf>newHttpClientBuilder(host, port).build();
}
代码示例来源:origin: io.reactivex/rxnetty
public static HttpServer<ByteBuf, ByteBuf> createHttpServer(int port, RequestHandler<ByteBuf, ByteBuf> requestHandler) {
return newHttpServerBuilder(port, requestHandler).build();
}
代码示例来源:origin: com.netflix.eureka/eureka2-server
public <T extends WebSocketFrame> void connectWebSocketEndpoint(String pathPrefix, ConnectionHandler<T, T> handler) {
WebSocketServer<T, T> backend = RxNetty.newWebSocketServerBuilder(0, handler).build();
backend.start();
backendServers.add(backend);
proxy.register(ForwardingRule.pathPrefix(backend.getServerPort(), pathPrefix));
logger.info("Started backend WebSocket server on port {} or {}", backend.getServerPort(), handler.getClass().getSimpleName());
}
代码示例来源:origin: io.reactivex/rxnetty
public static RxClient<ByteBuf, ByteBuf> createTcpClient(String host, int port) {
return RxNetty.<ByteBuf, ByteBuf>newTcpClientBuilder(host, port).build();
}
代码示例来源:origin: io.reactivex/rxnetty-tcp
public static <RR, WW> TcpServerState<RR, WW> create(SocketAddress socketAddress) {
return create(socketAddress, RxNetty.getRxEventLoopProvider().globalServerEventLoop(true),
RxNetty.isUsingNativeTransport() ? EpollServerSocketChannel.class : NioServerSocketChannel.class);
}
代码示例来源:origin: io.reactivex/rxnetty
public static <I, O> UdpServer<I, O> createUdpServer(final int port, PipelineConfigurator<I, O> pipelineConfigurator,
ConnectionHandler<I, O> connectionHandler) {
return newUdpServerBuilder(port, connectionHandler).pipelineConfigurator(pipelineConfigurator).build();
}
代码示例来源:origin: com.netflix.rxnetty/rx-netty
public static void main(String[] args) {
RxNetty.createHttpServer(8888, new RequestHandler<ByteBuf, ByteBuf>() {
@Override
public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
throw new NullPointerException("doomsday");
}
}).startAndWait();
}
}
代码示例来源:origin: io.reactivex/rxnetty
public static <I, O> RxServer<I, O> createTcpServer(final int port, PipelineConfigurator<I, O> pipelineConfigurator,
ConnectionHandler<I, O> connectionHandler) {
return newTcpServerBuilder(port, connectionHandler).pipelineConfigurator(pipelineConfigurator).build();
}
代码示例来源:origin: io.reactivex/rxnetty
public static HttpClient<ByteBuf, ByteBuf> createHttpClient(String host, int port) {
return RxNetty.<ByteBuf, ByteBuf>newHttpClientBuilder(host, port).build();
}
代码示例来源:origin: com.netflix.rxnetty/rx-netty
public static HttpServer<ByteBuf, ByteBuf> createHttpServer(int port, RequestHandler<ByteBuf, ByteBuf> requestHandler) {
return newHttpServerBuilder(port, requestHandler).build();
}
代码示例来源:origin: com.netflix.eureka/eureka2-dashboard
@PostConstruct
public void start() {
server = RxNetty.newWebSocketServerBuilder(config.getWebSocketPort(), new ConnectionHandler<WebSocketFrame, WebSocketFrame>() {
@Override
public Observable<Void> handle(final ObservableConnection<WebSocketFrame, WebSocketFrame> connection) {
return connection.getInput().flatMap(new Func1<WebSocketFrame, Observable<Void>>() {
@Override
public Observable<Void> call(WebSocketFrame wsFrame) {
if (wsFrame instanceof TextWebSocketFrame) {
TextWebSocketFrame textFrame = (TextWebSocketFrame) wsFrame;
logger.info("Got ws-message: " + textFrame.text());
final String cmd = textFrame.text();
if (cmd.equals("get status")) {
return streamEurekaStatus(connection);
} else {
// registry
return streamEurekaRegistryData(connection);
}
} else {
return Observable.empty();
}
}
});
}
}).build().start();
logger.info("Starting WebSocket server on port {}...", server.getServerPort());
}
代码示例来源:origin: com.netflix.rxnetty/rx-netty
public static RxClient<ByteBuf, ByteBuf> createTcpClient(String host, int port) {
return RxNetty.<ByteBuf, ByteBuf>newTcpClientBuilder(host, port).build();
}
代码示例来源:origin: com.netflix.rxnetty/rx-netty
public static <I, O> UdpServer<I, O> createUdpServer(final int port, PipelineConfigurator<I, O> pipelineConfigurator,
ConnectionHandler<I, O> connectionHandler) {
return newUdpServerBuilder(port, connectionHandler).pipelineConfigurator(pipelineConfigurator).build();
}
代码示例来源:origin: com.netflix.eureka2/eureka-testkit
public void start() {
httpServer = RxNetty.createHttpServer(VIEW_PORT, new RequestHandler<ByteBuf, ByteBuf>() {
@Override
public Observable<Void> handle(HttpServerRequest<ByteBuf> request, HttpServerResponse<ByteBuf> response) {
DeploymentReport report = createReport();
String result;
try {
result = MAPPER.writeValueAsString(report);
} catch (IOException e) {
return Observable.error(e);
}
return response.writeStringAndFlush(result);
}
}).start();
}
代码示例来源:origin: com.netflix.karyon/karyon2-governator
/**
* Creates a new {@link KaryonServer} that has a single TCP server instance which delegates all connection
* handling to {@link ConnectionHandler}.
* The {@link RxServer} is created using {@link RxNetty#newTcpServerBuilder(int, ConnectionHandler)}
*
* @param port Port for the server.
* @param handler Connection Handler
* @param bootstrapModules Additional bootstrapModules if any.
*
* @return {@link KaryonServer} which is to be used to start the created server.
*/
public static KaryonServer forTcpConnectionHandler(int port, ConnectionHandler<ByteBuf, ByteBuf> handler,
BootstrapModule... bootstrapModules) {
RxServer<ByteBuf, ByteBuf> server = RxNetty.newTcpServerBuilder(port, handler).build();
return new RxNettyServerBackedServer(server, bootstrapModules);
}
代码示例来源:origin: com.netflix.rxnetty/rx-netty
public static <I, O> HttpClient<I, O> createHttpClient(String host, int port,
PipelineConfigurator<HttpClientResponse<O>,
HttpClientRequest<I>> configurator) {
return RxNetty.<I, O>newHttpClientBuilder(host, port).pipelineConfigurator(configurator).build();
}
内容来源于网络,如有侵权,请联系作者删除!