Java Code Examples for io.netty.channel.ChannelPipeline#fireUserEventTriggered()

The following examples show how to use io.netty.channel.ChannelPipeline#fireUserEventTriggered() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpObjectAggregator.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: AbstractOioByteChannel.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
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());
        }
    }
}
 
Example 3
Source File: AbstractNioByteChannel.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 4
Source File: AbstractNioByteChannel.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
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());
        }
    }
}
 
Example 5
Source File: AbstractEpollStreamChannel.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
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());
        }
    }
}
 
Example 6
Source File: ProtocolHandshakeHandler.java    From jfxvnc with Apache License 2.0 5 votes vote down vote up
@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);

}