All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.godmao.mqbroker.handler.BrokerBaseHandler Maven / Gradle / Ivy

There is a newer version: 0.2.7.RELEASE
Show newest version
package com.godmao.mqbroker.handler;

import com.godmao.netty.handler.DefaultChannelInboundHandler;
import com.godmao.netty.handler.IConnect;
import io.netty.channel.ChannelHandlerContext;

// 必须放在责任链最后
public class BrokerBaseHandler extends DefaultChannelInboundHandler {
    public BrokerBaseHandler(IConnect connect) {
        super(connect);
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) {
        this.connect.getChannelService().add(ctx.channel());
        this.connect.getConnectHandler().onOpen(ctx);
    }


    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        this.connect.getConnectHandler().onError(ctx, cause);
    }


    @Override
    public void channelInactive(ChannelHandlerContext ctx) {
        this.connect.getConnectHandler().onClose(ctx);
    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) {
        this.connect.getConnectHandler().onMessage(ctx, msg);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy