下面列出了io.netty.channel.ChannelPipeline#fireUserEventTriggered ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static Object continueResponse(HttpMessage start, int maxContentLength, ChannelPipeline pipeline) {
if (HttpUtil.isUnsupportedExpectation(start)) {
// if the request contains an unsupported expectation, we return 417 如果请求包含不支持的期望,则返回417
pipeline.fireUserEventTriggered(HttpExpectationFailedEvent.INSTANCE);
return EXPECTATION_FAILED.retainedDuplicate();
} else if (HttpUtil.is100ContinueExpected(start)) {
// if the request contains 100-continue but the content-length is too large, we return 413如果请求包含100-continue,但内容长度太大,则返回413
if (getContentLength(start, -1L) <= maxContentLength) {
return CONTINUE.retainedDuplicate();
}
pipeline.fireUserEventTriggered(HttpExpectationFailedEvent.INSTANCE);
return TOO_LARGE.retainedDuplicate();
}
return null;
}
private void closeOnRead(ChannelPipeline pipeline) {
if (isOpen()) {
if (Boolean.TRUE.equals(config().getOption(ChannelOption.ALLOW_HALF_CLOSURE))) {
shutdownInput();
pipeline.fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
} else {
unsafe().close(unsafe().voidPromise());
}
}
}
private void closeOnRead(ChannelPipeline pipeline) {
if (!isInputShutdown0()) {
if (Boolean.TRUE.equals(config().getOption(ChannelOption.ALLOW_HALF_CLOSURE))) {
shutdownInput();
pipeline.fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
} else {
close(voidPromise());
}
} else {
pipeline.fireUserEventTriggered(ChannelInputShutdownReadComplete.INSTANCE);
}
}
private void closeOnRead(ChannelPipeline pipeline) {
SelectionKey key = selectionKey();
setInputShutdown();
if (isOpen()) {
if (Boolean.TRUE.equals(config().getOption(ChannelOption.ALLOW_HALF_CLOSURE))) {
key.interestOps(key.interestOps() & ~readInterestOp);
pipeline.fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
} else {
close(voidPromise());
}
}
}
private void closeOnRead(ChannelPipeline pipeline) {
inputShutdown = true;
if (isOpen()) {
if (Boolean.TRUE.equals(config().getOption(ChannelOption.ALLOW_HALF_CLOSURE))) {
clearEpollIn0();
pipeline.fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
} else {
close(voidPromise());
}
}
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof ProtocolVersion) {
handleServerVersion(ctx, (ProtocolVersion) msg);
return;
}
if (msg instanceof SecurityTypesEvent) {
handleSecurityTypes(ctx, (SecurityTypesEvent) msg);
return;
}
if (msg instanceof RfbSecurityMessage) {
handleSecurityMessage(ctx, (RfbSecurityMessage) msg);
return;
}
if (msg instanceof SecurityResultEvent) {
handleSecurityResult(ctx, (SecurityResultEvent) msg);
return;
}
if (msg instanceof ServerInitEvent) {
handshaker.finishHandshake(ctx.channel(), config.versionProperty().get());
ChannelPipeline cp = ctx.pipeline();
cp.fireUserEventTriggered(ProtocolState.HANDSHAKE_COMPLETE);
cp.remove(this);
cp.fireChannelRead(msg);
return;
}
throw new ProtocolException("unknown message occurred: " + msg);
}