From 38e4e60bb1fce4d2a8fe95adba35ec06d868412a Mon Sep 17 00:00:00 2001 From: panlili2024 <14743743+panlili2024@user.noreply.gitee.com> Date: 星期二, 31 十二月 2024 16:42:14 +0800 Subject: [PATCH] 代码同步 --- HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 deletions(-) diff --git a/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java b/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java index 91b96ae..68973ca 100644 --- a/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java +++ b/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java @@ -1,6 +1,7 @@ package com.hdl.sdk.connect.socket; import android.text.TextUtils; +import android.util.Log; import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -68,7 +69,7 @@ /** * instance */ - private volatile static HDLAuthSocket instance; + private static final HDLAuthSocket instance=new HDLAuthSocket(); private HDLAuthSocket() { initListenerGatewayEvent(); @@ -84,14 +85,14 @@ * * @return HDLAuthSocket */ - public static synchronized HDLAuthSocket getInstance() { - if (instance == null) { - synchronized (HDLLinkConfig.class) { - if (instance == null) { - instance = new HDLAuthSocket(); - } - } - } + public static HDLAuthSocket getInstance() { +// if (instance == null) { +// synchronized (HDLAuthSocket.class) { +// if (instance == null) { +// instance = new HDLAuthSocket(); +// } +// } +// } return instance; } @@ -110,14 +111,14 @@ * * @return 杩斿洖褰撳墠瀵硅薄 */ - private UdpSocketBoot getUdpBoot() { + private synchronized UdpSocketBoot getUdpBoot() { try { if (udpSocketBoot == null) { udpSocketBoot = UdpClient.init(UDP_PORT, getUdpOptions()); udpSocketBoot.bind(); } } catch (Exception e) { -// return null; + LogUtils.e("鍒濆鍖朣ocket udp寮傚父"+e.getMessage()); } return udpSocketBoot; @@ -136,9 +137,11 @@ //2.鏋勫缓鐩戝惉Listener // authEvent = //3.鐩戝惉缃戝叧骞挎挱鐨勫叆缃戞寚浠� + EventDispatcher.getInstance().remove(TopicConstant.GATEWAY_AUTH_BROADCAST); EventDispatcher.getInstance().register(TopicConstant.GATEWAY_AUTH_BROADCAST, new EventListener() { @Override public void onMessage(Object msg) { + LogUtils.i("鏀跺埌缃戝叧璁よ瘉淇℃伅: "); NetworkAccessBroadcastResponse bean = getNetworkAccessBroadcastResponse(msg); if (bean != null) { //绉婚櫎鐩戝惉 @@ -185,7 +188,8 @@ try { AuthenticateResponse bean = getAuthenticateResponseBean(msg); if (bean != null) { - if (bean.getCode().equals("200")) { + Log.i("TAG", "sendAuthenticateRequest code= " + bean.getCode()); + if (bean.getCode().equals("200") || bean.getCode().equals("0")) { String localSecret = ""; String gatewayId = ""; String ipAddress = ""; -- Gitblit v1.8.0