From 04122050f9b2bf5612d26f8394cc2ead03b57258 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期五, 10 十二月 2021 18:09:01 +0800 Subject: [PATCH] 2021-12-10 1.优化UDP发送 --- HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/SocketBoot.java | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/SocketBoot.java b/HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/SocketBoot.java index 8d206f5..92f7501 100644 --- a/HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/SocketBoot.java +++ b/HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/SocketBoot.java @@ -5,6 +5,7 @@ import androidx.collection.ArrayMap; +import com.hdl.sdk.common.utils.LogUtils; import com.hdl.sdk.common.utils.ThreadToolUtils; import com.hdl.sdk.socket.annotation.ConnectStatus; import com.hdl.sdk.socket.client.IClient; @@ -32,6 +33,10 @@ private ScheduledExecutorService delayThread; private final IClient client; + + public IClient getClient() { + return client; + } /** * socket鏄惁鍦ㄨ繍琛� @@ -67,7 +72,7 @@ final int maxRetry = client.getOptions().getMaxRetry(); if (maxRetry == 0 && resendCount.get() > 0 || (maxRetry > 0 && maxRetry + 1 < resendCount.get())) { - Log.d("====", "===閲嶈繛娆℃暟杈惧埌鏈�澶�=="); + LogUtils.d("====", "===閲嶈繛娆℃暟杈惧埌鏈�澶�=="); return; } if (!client.isConnect()) { @@ -82,7 +87,7 @@ try { resendCount.set(resendCount.get() + 1); Thread.sleep(300L); - Log.d("====", "==閲嶈繛绗�" + resendCount + "娆�=="); + LogUtils.d("====", "==閲嶈繛绗�" + resendCount + "娆�=="); } catch (Exception ignored) { } } @@ -90,7 +95,7 @@ client.connect(); isRun.set(true); if (client.isConnect()) { - Log.d("====", "====杩炴帴鎴愬姛===="); + LogUtils.d("====", "====杩炴帴鎴愬姛===="); startHeartbeat(); initSendThread(); @@ -103,7 +108,7 @@ } } catch (Exception e) { e.printStackTrace(); - Log.d("====", "===杩炴帴澶辫触===" + e); + LogUtils.d("====", "===杩炴帴澶辫触===" + e); //鍐嶅垽鏂竴涓嬫湁娌℃湁杩炴帴 if (!client.isConnect()) { isRun.set(false); @@ -126,12 +131,12 @@ public void run() { while (isRun.get()) { if (client.isConnect()) { - Log.d("=====", "==鍙戦�佹暟鎹�=="); + LogUtils.d("=====", "==鍙戦�佹暟鎹�=="); try { SocketRequest socketRequest = mMessageQueue.take(); final String sendStr = new String(socketRequest.getData(), 0, socketRequest.getData().length); - Log.d("=====", "==鍙戦�佹暟鎹�==锛�"+sendStr); + LogUtils.d("=====", "==鍙戦�佹暟鎹�==锛�"+sendStr); final String action = socketRequest.getAction(); try { client.sendMsg(socketRequest.getData()); @@ -165,7 +170,7 @@ } } - Log.d("=====", "==鍙戦�佺嚎绋嬪叧闂�=="); + LogUtils.d("=====", "==鍙戦�佺嚎绋嬪叧闂�=="); } }); @@ -185,7 +190,7 @@ client.onHandleResponse(); } catch (Exception e) { e.printStackTrace(); - Log.d("====", "鏂紑杩炴帴" + e.getMessage()); + LogUtils.d("====", "鏂紑杩炴帴" + e.getMessage()); disconnectError(); } } @@ -208,7 +213,7 @@ @Override public void run() { if (isRun.get()) { - Log.d("====", "===鍙戦�佸績璺冲寘==="); +// LogUtils.d("====", "===鍙戦�佸績璺冲寘==="); if (client.getOptions() != null) { final byte[] heartBeat = client.getOptions().getHeartbeatData(); if (heartBeat != null) { -- Gitblit v1.8.0