package com.yfd.platform.component.nettyserver;

import cn.hutool.core.util.ObjUtil;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 *  TCP通道缓存
 */
public class BootSessionCache {

    public static volatile Map<String, Long> requestSessionID = new ConcurrentHashMap<String, Long>();

    public static volatile Map<String, Long> responeSessionID = new ConcurrentHashMap<String, Long>();

    public static long getRequestSessionID(){
        Long id=0L;
        if(ObjUtil.isEmpty(BootSessionCache.requestSessionID.get("requestid"))){
           BootSessionCache.requestSessionID.put("requestid",1L);
           return 1L;
        }
        id=Long.parseLong(BootSessionCache.requestSessionID.get("requestid").toString());
        id=id+1;
        BootSessionCache.requestSessionID.put("requestid",id);
        return id;
    }

    public static long getResponseSessionID(){
        Long id=0L;
        if(ObjUtil.isEmpty(BootSessionCache.responeSessionID.get("responeid"))){
            BootSessionCache.responeSessionID.put("responeid",1L);
            return 1L;
        }
        id=Long.parseLong(BootSessionCache.responeSessionID.get("responeid").toString());
        id=id+1;
        BootSessionCache.responeSessionID.put("responeid",id);
        return id;
    }


}
