hxb
2022-04-13 a61093fc99633b2e5d6a7a14ddd91f26ce2e24ab
HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/SocketBoot.java
@@ -1,9 +1,9 @@
package com.hdl.sdk.socket;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.util.Log;
import androidx.collection.ArrayMap;
import com.google.gson.JsonObject;
import com.hdl.sdk.common.config.TopicConstant;
@@ -74,9 +74,10 @@
        try {
            LogUtils.i("TCP连接");
            client.onConnectStatus(ConnectStatus.CONNECTING);
            Thread.sleep(700);
            Thread.sleep(1000);
            client.connect();
            connected=true;
            LogUtils.i("TCP连接成功");
            client.onConnectStatus(ConnectStatus.CONNECTED);
        }catch(Exception e) {
            LogUtils.e("连接异常"+e.getMessage());
@@ -175,7 +176,7 @@
                            }
                            Thread.sleep(3*1000);
                        } catch (Exception e) {
                            LogUtils.e("定时连接失败:" + e.getMessage());
                        }
                    }
                }
@@ -198,15 +199,12 @@
                            if (connected && 10 * 1000 < (System.currentTimeMillis() - time)) {
                                time = System.currentTimeMillis();
                                //心跳检测
                                try {
                                    if (iHeartbeat != null)
                                        iHeartbeat.heartbeat();
                                } catch (Exception e) {
                                }
                                if (iHeartbeat != null)
                                    iHeartbeat.heartbeat();
                            }
                            Thread.sleep(1000);
                        } catch (Exception e) {
                            LogUtils.e("定时心跳检测网关异常:" + e.getMessage());
                        }
                    }
                }
@@ -243,7 +241,7 @@
            }
            mMessageQueue.put(request);
        } catch (Exception e) {
            LogUtils.e("发送数据失败:" + e.getMessage());
        }
    }