public class AsityServerCodec
extends io.netty.channel.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 -> {}));
| Constructor and Description |
|---|
AsityServerCodec() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
accept(io.netty.handler.codec.http.HttpRequest req)
Whether to process this request or not.
|
void |
channelInactive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
void |
exceptionCaught(io.netty.channel.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, userEventTriggeredensureNotSharable, handlerAdded, handlerRemoved, isSharablepublic void channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
channelRead in interface io.netty.channel.ChannelInboundHandlerchannelRead in class io.netty.channel.ChannelInboundHandlerAdapterprotected boolean accept(io.netty.handler.codec.http.HttpRequest req)
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
exceptionCaught in interface io.netty.channel.ChannelHandlerexceptionCaught in interface io.netty.channel.ChannelInboundHandlerexceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapterpublic void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
channelInactive in interface io.netty.channel.ChannelInboundHandlerchannelInactive in class io.netty.channel.ChannelInboundHandlerAdapterpublic AsityServerCodec onhttp(Action<ServerHttpExchange> action)
ServerHttpExchange is
available.public AsityServerCodec onwebsocket(Action<ServerWebSocket> action)
ServerWebSocket is
available.Copyright © 2015–2019. All rights reserved.