package org.nl.config.lucene.remote;

import io.netty.bootstrap.AbstractBootstrap;
import io.netty.channel.Channel;

import java.net.SocketAddress;

/*
 * @author ZZQ
 * @Date 2024/1/22 10:01
 */
public abstract class AbstraceServer {


    public AbstraceServer(SocketAddress address) {
        this.address = address;
        if (channel!=null){
            doDestroy();
        }
        doOpen();
        doConnect();
    }

    public AbstractBootstrap server;
    public SocketAddress address;
    public Channel channel;

    public abstract void doOpen();

    public void doDestroy(){
        if (channel!=null){
            channel.close();
        }
    };

    public abstract void doConnect() ;

    public void doDisConnect(){
        if (channel!=null){
            channel.close();
            channel.flush();
            doConnect();
        }
    };
}
