public abstract class VibeServerCodec 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 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();
}
});
ChannelHandler.Sharable| 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 abstract Action<ServerHttpExchange> |
httpAction()
An
Action to consume ServerHttpExchange. |
abstract Action<ServerWebSocket> |
wsAction()
An
Action to consume ServerWebSocket. |
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 ChannelInboundHandlerAdapterprotected abstract Action<ServerHttpExchange> httpAction()
Action to consume ServerHttpExchange.public abstract Action<ServerWebSocket> wsAction()
Action to consume ServerWebSocket.Copyright 2014, The Vibe Project