io.netty.channel.DefaultChannelPipeline Java Examples

The following examples show how to use io.netty.channel.DefaultChannelPipeline. 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: MobileLoginHandler.java    From blynk-server with GNU General Public License v3.0 6 votes vote down vote up
private void login(ChannelHandlerContext ctx, int messageId, User user, Version version) {
    var pipeline = (DefaultChannelPipeline) ctx.pipeline();
    cleanPipeline(pipeline);

    var appStateHolder = new MobileStateHolder(user, version);
    pipeline.addLast("AAppHandler", new MobileHandler(holder, appStateHolder));

    var channel = ctx.channel();

    //todo back compatibility code. remove in future.
    if (user.region == null || user.region.isEmpty()) {
        user.region = holder.props.region;
    }

    var session = holder.sessionDao.getOrCreateSessionByUser(appStateHolder.userKey, channel.eventLoop());
    if (session.isSameEventLoop(channel)) {
        completeLogin(channel, session, user, messageId, version);
    } else {
        log.debug("Re registering app channel. {}", ctx.channel());
        ReregisterChannelUtil.reRegisterChannel(ctx, session, channelFuture ->
                completeLogin(channelFuture.channel(), session, user, messageId, version));
    }
}
 
Example #2
Source File: MobileLoginHandler.java    From blynk-server with GNU General Public License v3.0 5 votes vote down vote up
private static void cleanPipeline(DefaultChannelPipeline pipeline) {
    pipeline.removeIfExists(MobileLoginHandler.class);
    pipeline.removeIfExists(UserNotLoggedHandler.class);
    pipeline.removeIfExists(MobileGetServerHandler.class);
    pipeline.removeIfExists(MobileRegisterHandler.class);
    pipeline.removeIfExists(MobileShareLoginHandler.class);
    pipeline.removeIfExists(MobileResetPasswordHandler.class);
}
 
Example #3
Source File: EmbeddedChannel.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Override
protected final DefaultChannelPipeline newChannelPipeline() {
    return new EmbeddedChannelPipeline(this);
}
 
Example #4
Source File: FlowHandlerTest.java    From pravega with Apache License 2.0 4 votes vote down vote up
private ChannelFuture failedFuture(String message) {
    DefaultChannelPipeline pipeline = new DefaultChannelPipeline(ch) {
    };
    return pipeline.newFailedFuture(new RuntimeException(message));
}