hxb
2024-08-20 0a8fd4aa92555875f58f67144c2c0c0a20a200af
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLSocket.java
@@ -109,7 +109,7 @@
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                        Thread.sleep(5000);
//                        LogUtils.i("checkIfCertified=" + HDLLink.getInstance().checkIfCertified() + " getTcp().connected=" + getTcp().connected);
                        try {
                            if (!HDLLink.getInstance().checkIfCertified() || (!TextUtils.isEmpty(getTcpIp()) && getTcp().connected)) {
@@ -473,14 +473,15 @@
        }
    }
    public SocketBoot getTcp() throws RuntimeException {
        if (TextUtils.isEmpty(getTcpIp())) {
    public synchronized SocketBoot  getTcp() throws RuntimeException {
        String gatewayIpAddress=getTcpIp();
        if (TextUtils.isEmpty(gatewayIpAddress)) {
            LogUtils.e("请搜索网关");
            throw new RuntimeException("请搜索网关");
        }
        //如果没有初始化,或者网关IP更改了,就重新初始化
        if (tcpBoot == null || !getTcpOptions().getIp().equals(getTcpIp())) {
            tcpBoot = TcpClient.init(getTcpIp(), getTcpPort(), getTcpOptions());
        if (tcpBoot == null || !getTcpOptions().getIp().equals(gatewayIpAddress)) {
            tcpBoot = TcpClient.init(gatewayIpAddress, getTcpPort(), getTcpOptions());
            tcpBoot.SetHeartbeat(new IHeartbeat() {
                @Override
                public void heartbeat() {