package com.mortals.xhx.common.utils;

import com.mortals.framework.util.StringUtils;
import lombok.Data;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

@Data
public abstract class GateProtConfig {

    /**提交URL*/
    private String sendUrl;
    /**
     * 流量数
     */
    private Integer mtFlux;

    /**
     * 状态
     */
    private Integer state;

    /**
     * 配置参数
     */
    private String paramConfig;

    /**
     * 发送延迟
     */
    private Integer SendDelayTime = 1 * 1000;

    /**
     *
     */
    private Integer maxDelayNum = 50;


    public GateProtConfig(String xml) throws Exception {
        if (StringUtils.isEmpty(xml)) {
            return;
        }

        Document doc = null;
        doc = DocumentHelper.parseText(xml);
        Element root = doc.getRootElement();
        analyze(root);
    }

    /**
     * 解析xml处理
     */
    public abstract void analyze(Element root) throws Exception;

}
