From 755e2893c12b79649ee12dec2b7d832d58b9265b Mon Sep 17 00:00:00 2001 From: 562935844@qq.com Date: 星期三, 18 十月 2023 16:19:26 +0800 Subject: [PATCH] 上报oid列表新增parentoid --- HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/socket/client/UdpClient.java | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-) diff --git a/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/socket/client/UdpClient.java b/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/socket/client/UdpClient.java index f9b9670..3980879 100644 --- a/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/socket/client/UdpClient.java +++ b/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/socket/client/UdpClient.java @@ -29,7 +29,7 @@ /** * 褰撳墠socket */ - private DatagramSocket mSocket; + private DatagramSocket mSocket; /** * 鎺ユ敹鏁版嵁鍖� @@ -57,11 +57,12 @@ /** * 鍒濆鍖栧弬鏁� - * @param ipAddress 鏈湴鐩戝惉绔彛 - * @param port 鏈湴鐩戝惉绔彛 + * + * @param ipAddress 鏈湴鐩戝惉绔彛 + * @param port 鏈湴鐩戝惉绔彛 * @param socketOptions */ - private UdpClient(String ipAddress,int port, UdpSocketOptions socketOptions) { + private UdpClient(String ipAddress, int port, UdpSocketOptions socketOptions) { this.ipAddress = ipAddress; this.port = port; this.socketOptions = socketOptions; @@ -71,8 +72,9 @@ /** * 鍒濆鍖栧弬鏁� + * * @param ipAddress 鏈湴鐩戝惉IP鍦板潃 - * @param port 鏈湴鐩戝惉绔彛 + * @param port 鏈湴鐩戝惉绔彛 * @param options * @return */ @@ -82,7 +84,8 @@ /** * 鍒濆鍖栧弬鏁� - * @param port 鏈湴鐩戝惉绔彛 + * + * @param port 鏈湴鐩戝惉绔彛 * @param options * @return */ @@ -100,8 +103,8 @@ } if (TextUtils.isEmpty(ipAddress)) { mSocket = SocketPool.getInstance().getUdpSocket(new InetSocketAddress(port)); - }else { - mSocket = SocketPool.getInstance().getUdpSocket(new InetSocketAddress(ipAddress,port)); + } else { + mSocket = SocketPool.getInstance().getUdpSocket(new InetSocketAddress(ipAddress, port)); } mSocket.setBroadcast(true); // mSocket.setReuseAddress(true); @@ -150,13 +153,13 @@ } try { - LogUtils.i("鎺ユ敹鍒癠dp鏁版嵁鍖咃紝缃戠粶鍦板潃锛�" + receivePacket.getAddress().getHostAddress() + ":" + receivePacket.getPort()); +// LogUtils.i("鎺ユ敹鍒癠dp鏁版嵁鍖咃紝缃戠粶鍦板潃锛�" + receivePacket.getAddress().getHostAddress() + ":" + receivePacket.getPort()); IHandleMessage handleMessage = getOptions().getHandleMessage(); if (handleMessage != null) { byte[] data = new byte[receivePacket.getLength()]; System.arraycopy(receivePacket.getData(), 0, data, 0, data.length); - handleMessage.read(data,receivePacket.getAddress().getHostAddress()); + handleMessage.read(data, receivePacket.getAddress().getHostAddress()); } } catch (Exception e) { @@ -166,11 +169,12 @@ @Override - public void sendMsg(String ipAddress,int port, byte[] msg) throws Exception { + public void sendMsg(String ipAddress, int port, byte[] msg) throws Exception { if (msg == null) { return; } final DatagramPacket sendPacket = new DatagramPacket(msg, msg.length, InetAddress.getByName(ipAddress), port); + if (sendPacket == null) return; mSocket.send(sendPacket); } } -- Gitblit v1.8.0