public class VibeServerCodec
extends ChannelInboundHandlerAdapter
HttpRequest and HttpResponse into
NettyServerHttpExchange and NettyServerWebSocket. You need to
configure this handler and provide your action to receive
ServerHttpExchange and ServerWebSocket by overriding
httpAction() and wsAction()
like the following usage. When you configure handler, you must add
HttpServerCodec in front of this handler.
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new HttpServerCodec())
.addLast(new VibeServerCodec() {
@Override
protected boolean accept(HttpRequest req) {
return URI.create(req.getUri()).getPath().equals("/vibe");
}
@Override
protected Action<ServerHttpExchange> httpAction() {
return server.httpAction();
}
@Override
public Action<ServerWebSocket> wsAction() {
return server.websocketAction();
}
});
| Constructor and Description |
|---|
VibeServerCodec() |
| 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) |
protected |
httpAction()
An
Action to consume ServerHttpExchange. |
|
wsAction()
An
Action to consume ServerWebSocket. |
public void channelRead(ChannelHandlerContext ctx,
Object msg)
protected boolean accept(HttpRequest req)
public void exceptionCaught(ChannelHandlerContext ctx,
Throwable cause)
public void channelInactive(ChannelHandlerContext ctx)
protectedhttpAction()
Action to consume ServerHttpExchange. By default, it
throws IllegalStateException so you should provide your action by
overriding it.publicwsAction()
Action to consume ServerWebSocket. By default, it
throws IllegalStateException so you should provide your action by
overriding it.Copyright 2014, The Vibe Project