fix:Add logs

This commit is contained in:
SL 2025-01-06 22:16:23 +08:00
parent c7a468a2b0
commit 9978523a9a
3 changed files with 8 additions and 4 deletions

View File

@ -91,7 +91,7 @@ public class WKConnection {
private String lastRequestId; private String lastRequestId;
private int unReceivePongCount = 0; private int unReceivePongCount = 0;
public volatile Handler reconnectionHandler = new Handler(Objects.requireNonNull(Looper.myLooper())); public volatile Handler reconnectionHandler = new Handler(Objects.requireNonNull(Looper.myLooper()));
// private final Handler mainHandler = new Handler(Looper.getMainLooper()); // private final Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable reconnectionRunnable = this::reconnection; Runnable reconnectionRunnable = this::reconnection;
private int connCount = 0; private int connCount = 0;
@ -168,11 +168,13 @@ public class WKConnection {
connectionClient = new ConnectionClient(iNonBlockingConnection -> { connectionClient = new ConnectionClient(iNonBlockingConnection -> {
connCount = 0; connCount = 0;
if (iNonBlockingConnection == null || connection == null || !connection.getId().equals(iNonBlockingConnection.getId())) { if (iNonBlockingConnection == null || connection == null || !connection.getId().equals(iNonBlockingConnection.getId())) {
WKLoggerUtils.getInstance().e(TAG,"重复连接");
forcedReconnection(); forcedReconnection();
return; return;
} }
Object att = iNonBlockingConnection.getAttachment(); Object att = iNonBlockingConnection.getAttachment();
if (att == null || !att.equals(socketSingleID)) { if (att == null || !att.equals(socketSingleID)) {
WKLoggerUtils.getInstance().e(TAG,"不属于当前连接");
forcedReconnection(); forcedReconnection();
return; return;
} }

View File

@ -220,6 +220,7 @@ class WKProto {
receivedMsg.topicID = wkRead.readString(); receivedMsg.topicID = wkRead.readString();
} }
String content = wkRead.readPayload(); String content = wkRead.readPayload();
WKLoggerUtils.getInstance().e(TAG, "消息payload:" + content);
receivedMsg.payload = CryptoUtils.getInstance().aesDecrypt(CryptoUtils.getInstance().base64Decode(content)); receivedMsg.payload = CryptoUtils.getInstance().aesDecrypt(CryptoUtils.getInstance().base64Decode(content));
String msgKey = receivedMsg.messageID String msgKey = receivedMsg.messageID
+ receivedMsg.messageSeq + receivedMsg.messageSeq

View File

@ -102,10 +102,10 @@ public class CryptoUtils {
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException |
InvalidAlgorithmParameterException | IllegalBlockSizeException | InvalidAlgorithmParameterException | IllegalBlockSizeException |
BadPaddingException e) { BadPaddingException e) {
WKLoggerUtils.getInstance().e(TAG,"aesEncrypt encrypt error"); WKLoggerUtils.getInstance().e(TAG, "aesEncrypt encrypt error");
} }
if (encrypted == null) { if (encrypted == null) {
WKLoggerUtils.getInstance().e(TAG,"aesEncrypt The encrypted data is empty"); WKLoggerUtils.getInstance().e(TAG, "aesEncrypt The encrypted data is empty");
encrypted = sSrc.getBytes(); encrypted = sSrc.getBytes();
} }
return encrypted; return encrypted;
@ -136,8 +136,9 @@ public class CryptoUtils {
return content; return content;
} }
public byte[] base64Decode(String data) { public byte[] base64Decode(String data) {
return Base64.decode(data, Base64.NO_WRAP); return Base64.decode(data, Base64.NO_WRAP);
} }
/** /**