mac
2023-10-26 de2d3696f975cf6e6df2e580bab305fa9859feea
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/TcpSocketBoot.java
@@ -30,9 +30,11 @@
    private final IClient client;
    private IHeartbeat iHeartbeat;
    public void SetHeartbeat(IHeartbeat iHeartbeat){
        this.iHeartbeat=iHeartbeat;
    }
    /**
     * 当前接收到数据的时间
     */
@@ -66,10 +68,11 @@
    /**
     * 记录所有SocketBoot
     */
    final static List<TcpSocketBoot> TCP_SOCKET_BOOT_LIST = new ArrayList();
    final static List<TcpSocketBoot> TCP_SOCKET_BOOT_LIST = new ArrayList<>();
    /**
     * 根据IP地址及端口获取当前socketBoot
     *
     * @param ipAddress
     * @param port
     * @return
@@ -79,8 +82,7 @@
            return  null;
        }
        for(TcpSocketBoot tcpSocketBoot : TCP_SOCKET_BOOT_LIST){
            if(ipAddress.equals(tcpSocketBoot.getClient().getOptions().getIp())&& tcpSocketBoot.getClient().getOptions().getPort()==port)
            {
            if (ipAddress.equals(tcpSocketBoot.getClient().getOptions().getIp()) && tcpSocketBoot.getClient().getOptions().getPort() == port) {
                return tcpSocketBoot;
            }
        }
@@ -116,7 +118,7 @@
                public void run() {
                    while (true) {
                        try {
                            if(connected==false){
                            if (!connected) {
                                Thread.sleep(100);
                                continue;
                            }
@@ -234,6 +236,7 @@
            });
        }
    }
    /**
     * 重新连接
     */
@@ -244,6 +247,7 @@
    /**
     * 发送无需回调
     *
     * @param msg 发送的数据
     */
    public void sendMsg(byte[] msg) {
@@ -278,4 +282,31 @@
        }
    }
//    /**
//     * 断开全部的Link网关连接
//     */
//    public static void stopAllConnectLinkGateway() {
//        for (TcpSocketBoot data : TCP_SOCKET_BOOT_LIST) {
//            //断开指定的link网关连接
//            stopConnectLinkGateway(data);
//        }
//
//    }
//
//    /**
//     * 断开指定的link网关连接
//     *
//     * @param tcpSocketBoot tcp对象
//     */
//    public static void stopConnectLinkGateway(TcpSocketBoot tcpSocketBoot) {
//        synchronized (TCP_SOCKET_BOOT_LIST) {
//            try {
//                TCP_SOCKET_BOOT_LIST.remove(tcpSocketBoot);
//                tcpSocketBoot.client.disconnect();
//            } catch (Exception ignored) {
//            }
//        }
//    }
}