package com.cm.central.control.client.socket.config.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: SocketClientProperties
 * @Description: Socket客户端配置
 * @Author: WangGeng
 * @Date: 2020/7/29 10:06 上午
 * @Version: 1.0
 **/
@Component
@ConfigurationProperties(prefix = "socket.central-control.client")
public class SocketClientProperties {

    private String clientId;
    private String clientSecret;
    private String host = "127.0.0.1";
    private int port = 9999;
    private int maxReconnectCount = 20;
    private int reconnectTimeStep = 0;
    private int delayPingSeconds = 3;
    private Boolean sendClientInfoActive = false;
    private int sendClientInfoSecond = 10;

    public String getClientId() {
        return clientId == null ? "" : clientId.trim();
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public String getClientSecret() {
        return clientSecret == null ? "" : clientSecret.trim();
    }

    public void setClientSecret(String clientSecret) {
        this.clientSecret = clientSecret;
    }

    public String getHost() {
        return host == null ? "" : host.trim();
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public int getMaxReconnectCount() {
        return maxReconnectCount <= 0 ? 20 : maxReconnectCount;
    }

    public void setMaxReconnectCount(int maxReconnectCount) {
        this.maxReconnectCount = maxReconnectCount;
    }

    public int getReconnectTimeStep() {
        return reconnectTimeStep <= 0 ? 0 : reconnectTimeStep;
    }

    public void setReconnectTimeStep(int reconnectTimeStep) {
        this.reconnectTimeStep = reconnectTimeStep;
    }

    public int getDelayPingSeconds() {
        return delayPingSeconds <= 0 ? 3 : delayPingSeconds;
    }

    public void setDelayPingSeconds(int delayPingSeconds) {
        this.delayPingSeconds = delayPingSeconds;
    }

    public Boolean getSendClientInfoActive() {
        return sendClientInfoActive == null ? false : sendClientInfoActive;
    }

    public void setSendClientInfoActive(Boolean sendClientInfoActive) {
        this.sendClientInfoActive = sendClientInfoActive;
    }

    public int getSendClientInfoSecond() {
        return sendClientInfoSecond <= 10 ? 10 : sendClientInfoSecond;
    }

    public void setSendClientInfoSecond(int sendClientInfoSecond) {
        this.sendClientInfoSecond = sendClientInfoSecond;
    }
}
