package com.cm.central.control.client.socket.manager;


import io.netty.channel.Channel;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: SocketClientManager
 * @Description: Socket客户端控制器
 * @Author: WangGeng
 * @Date: 2020/7/29 3:12 下午
 * @Version: 1.0
 **/
public class SocketClientManager {

    private static SocketClientManager socketClientManager = SocketClientManagerBuilder.socketClientManager;
    private String token;
    private int currentReconnectCount = 1;
    private int currentReconnectTime = 1;
    private Channel channel;

    private SocketClientManager() {

    }

    public static SocketClientManager getInstance() {
        return socketClientManager;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getToken() {
        return token == null ? "" : token.trim();
    }

    public int getCurrentReconnectCount() {
        return currentReconnectCount;
    }

    public void setCurrentReconnectCount(int currentReconnectCount) {
        this.currentReconnectCount = currentReconnectCount;
    }

    public int getCurrentReconnectTime() {
        return currentReconnectTime;
    }

    public void setCurrentReconnectTime(int currentReconnectTime) {
        this.currentReconnectTime = currentReconnectTime;
    }

    private static class SocketClientManagerBuilder {
        public static SocketClientManager socketClientManager = new SocketClientManager();
    }

    public Channel getChannel() {
        return channel;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }
}
