| | |
| | | |
| | | |
| | | import com.fzzy.api.utils.BytesUtil; |
| | | import com.fzzy.protocol.bhzn.server.BhznGrainV2ServerUtils; |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import com.ld.io.api.IoSession; |
| | | |
| | | import java.util.HashMap; |
| | |
| | | * 记录每个连接的最后一次信息时间 key = 连接的KYE,data =当前时间戳 |
| | | */ |
| | | public static Map<String, Long> contextMapHeart = new HashMap<>(); |
| | | public static Map<String, IoSession> contextIoSession = new HashMap<>(); |
| | | |
| | | |
| | | public static GatewayDevice contextOrder = new GatewayDevice(); |
| | | public static int HEART_BEAT_TIME = 30;//心跳间隔时间 |
| | | |
| | | |
| | | public static String MSG_START = "3C42485A4E3E";//<BHZN> |
| | | public static String MSG_START2 = "AA"; |
| | | public static String MSG_END = "<END>";//<END> |
| | | public static String MSG_END_16 = "3C454E443E";//<END> |
| | | public static String MSG_END_16 = "3C454E443E";//<END>3C454E443E |
| | | public static final String CHARSET = "UTF-8"; |
| | | |
| | | |
| | |
| | | * @return |
| | | */ |
| | | public static String getCheck(String content) { |
| | | int start = BhznGrainV2ServerUtils.MSG_START.length() + BhznGrainV2ServerUtils.MSG_START2.length(); |
| | | int start = BhznGrainV0ServerUtils.MSG_START.length() + BhznGrainV0ServerUtils.MSG_START2.length(); |
| | | content = content.substring(start); |
| | | int sum = 0; |
| | | String hex; |
| | |
| | | |
| | | return BytesUtil.intToHexStr(256 - check).substring(2); |
| | | } |
| | | |
| | | public static void addSession(IoSession session) { |
| | | contextIoSession.put(DEFAULT_MAC_ID, session); |
| | | } |
| | | |
| | | public static IoSession getSession() { |
| | | return contextIoSession.get(DEFAULT_MAC_ID); |
| | | } |
| | | } |