public class AsityServerCodec extends ChannelInboundHandlerAdapter
HttpRequest and HttpResponse into
NettyServerHttpExchange and NettyServerWebSocket. When you
configure handler, you must add HttpServerCodec in
front of this handler.
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new HttpServerCodec())
.addLast(new AsityServerCodec() {
@Override
protected boolean accept(HttpRequest req) {
return URI.create(req.getUri()).getPath().equals("/cettia");
}
}
.onhttp(http -> {}).onwebsocket(ws -> {}));
ChannelHandler.Sharable| Constructor and Description |
|---|
AsityServerCodec() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
accept(HttpRequest req)
Whether to process this request or not.
|
void |
channelInactive(ChannelHandlerContext ctx) |
void |
channelRead(ChannelHandlerContext ctx,
Object msg) |
void |
exceptionCaught(ChannelHandlerContext ctx,
Throwable cause) |
AsityServerCodec |
onhttp(Action<ServerHttpExchange> action)
Registers an action to be called when
ServerHttpExchange is
available. |
AsityServerCodec |
onwebsocket(Action<ServerWebSocket> action)
Registers an action to be called when
ServerWebSocket is
available. |
channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredhandlerAdded, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAdded, handlerRemovedpublic void channelRead(ChannelHandlerContext ctx, Object msg)
channelRead in interface ChannelInboundHandlerchannelRead in class ChannelInboundHandlerAdapterprotected boolean accept(HttpRequest req)
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
exceptionCaught in interface ChannelHandlerexceptionCaught in interface ChannelInboundHandlerexceptionCaught in class ChannelInboundHandlerAdapterpublic void channelInactive(ChannelHandlerContext ctx)
channelInactive in interface ChannelInboundHandlerchannelInactive in class ChannelInboundHandlerAdapterpublic AsityServerCodec onhttp(Action<ServerHttpExchange> action)
ServerHttpExchange is
available.public AsityServerCodec onwebsocket(Action<ServerWebSocket> action)
ServerWebSocket is
available.Copyright © 2015–2018. All rights reserved.