Example usage for io.netty.channel ChannelPipeline fireChannelRead

List of usage examples for io.netty.channel ChannelPipeline fireChannelRead

Introduction

In this page you can find the example usage for io.netty.channel ChannelPipeline fireChannelRead.

Prototype

@Override
    ChannelPipeline fireChannelRead(Object msg);

Source Link

Usage

From source file:org.jfxvnc.net.rfb.codec.ProtocolHandshakeHandler.java

License:Apache License

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {

    if (msg instanceof ProtocolVersion) {
        handleServerVersion(ctx, (ProtocolVersion) msg);
        return;/*from   w w  w. jav a 2  s  .co  m*/
    }
    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);

}