package ink.wgink.pojo.session;

import io.netty.channel.Channel;

import java.io.Serializable;

/**
 * @ClassName: WebSocketUser
 * @Description: webSocket用户
 * @Author: wanggeng
 * @Date: 2021/9/11 11:28 下午
 * @Version: 1.0
 */
public class WebSocketSession implements Serializable {

    /**
     * 会话ID，登录时返回，socket注册时携带
     */
    private String sessionId;
    /**
     * 用户ID
     */
    private String userId;
    /**
     * 客户端名称，同一用户的同一客户端只能有一个
     */
    private String clientName;
    /**
     * 通道ID
     */
    private String channelId;
    /**
     * 通道
     */
    private Channel channel;
    /**
     * 更新时间
     */
    private Long updateTime;

    public String getSessionId() {
        return sessionId == null ? "" : sessionId.trim();
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getUserId() {
        return userId == null ? "" : userId.trim();
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getClientName() {
        return clientName == null ? "" : clientName.trim();
    }

    public void setClientName(String clientName) {
        this.clientName = clientName;
    }

    public String getChannelId() {
        return channelId == null ? "" : channelId.trim();
    }

    public void setChannelId(String channelId) {
        this.channelId = channelId;
    }

    public Channel getChannel() {
        return channel;
    }

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

    public Long getUpdateTime() {
        return updateTime == null ? 0 : updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"sessionId\":\"")
                .append(sessionId).append('\"');
        sb.append(",\"userId\":\"")
                .append(userId).append('\"');
        sb.append(",\"clientName\":\"")
                .append(clientName).append('\"');
        sb.append(",\"channelId\":\"")
                .append(channelId).append('\"');
        sb.append(",\"channel\":")
                .append(channel);
        sb.append(",\"updateTime\":")
                .append(updateTime);
        sb.append('}');
        return sb.toString();
    }
}
