use of info.xiancloud.nettyhttpserver.http.bean.Request in project xian by happyyangyuan.
the class RequestDecoderAux method decode.
@Override
protected void decode(ChannelHandlerContext ctx, FullHttpRequest msg, List<Object> out) throws Exception {
LOG.debug(" httpRequest ----> UnitRequest Pojo");
/*if (!HttpMethod.POST.equals(msg.method())) {
throw new BadRequestException(new IllegalArgumentException("拒绝非POST请求!"));
}*/
DecoderResult result = msg.decoderResult();
if (!result.isSuccess()) {
throw new BadRequestException(result.cause());
}
updateLongConnectionStatus(msg, ctx);
Request request = new Request(msg, MsgIdHolder.get());
offerReqQueue(ctx, request);
out.add(request);
}
use of info.xiancloud.nettyhttpserver.http.bean.Request in project xian by happyyangyuan.
the class IdleEventListener method userEventTriggered.
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof IdleStateEvent) {
IdleStateEvent event = (IdleStateEvent) evt;
LOG.info(ctx.channel().remoteAddress() + "超时类型:" + event.state().name());
if (event.state() == IdleState.WRITER_IDLE) {
List<Request> timeoutRequests = ctx.channel().attr(ReqQueue.REQ_QUEUE).get().removeTimeout();
for (Request timeoutRequest : timeoutRequests) {
timeoutRequest.getChannelHandlerContext().writeAndFlush(buildTimeoutResponse(timeoutRequest));
}
}
} else {
super.userEventTriggered(ctx, evt);
}
}
use of info.xiancloud.nettyhttpserver.http.bean.Request in project xian by happyyangyuan.
the class BusinessHandler method channelRead.
@Override
public void channelRead(final ChannelHandlerContext ctx, final Object request0) throws Exception {
Request request = (Request) request0;
request.setChannelHandlerContext(ctx);
forUseCase(ctx, request);
ctx.fireChannelRead(request);
}
Aggregations