package com.its.vds.xnettcp.center.handler;

import io.netty.channel.*;
import org.springframework.stereotype.Component;

@Component
@ChannelHandler.Sharable
public class CenterTcpServerOutboundHandler extends ChannelOutboundHandlerAdapter {

    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
        promise.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture f) {
                if (!f.isSuccess()) {
                    f.cause().printStackTrace();
                    f.channel().close();
                }
            }
        });
    }
}
