diff --git a/.idea/WhatsJava.iml b/.idea/WhatsJava.iml new file mode 100644 index 0000000..f8dcd41 --- /dev/null +++ b/.idea/WhatsJava.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..a5cd3c1 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/build/classes/java/main/icu/jnet/whatsjava/Main$1.class b/build/classes/java/main/icu/jnet/whatsjava/Main$1.class index 4371e8a..14f9daa 100644 Binary files a/build/classes/java/main/icu/jnet/whatsjava/Main$1.class and b/build/classes/java/main/icu/jnet/whatsjava/Main$1.class differ diff --git a/build/classes/java/main/icu/jnet/whatsjava/Main.class b/build/classes/java/main/icu/jnet/whatsjava/Main.class index 356f115..31d5e21 100644 Binary files a/build/classes/java/main/icu/jnet/whatsjava/Main.class and b/build/classes/java/main/icu/jnet/whatsjava/Main.class differ diff --git a/src/main/java/icu/jnet/whatsjava/messages/WAMessageParser.java b/src/main/java/icu/jnet/whatsjava/messages/WAMessageParser.java index dfd534b..167f46f 100644 --- a/src/main/java/icu/jnet/whatsjava/messages/WAMessageParser.java +++ b/src/main/java/icu/jnet/whatsjava/messages/WAMessageParser.java @@ -93,7 +93,7 @@ private static WAMessage[] messageToObject(JsonArray childrenArray) { // Convert json message of the type "chat" into WAChat private static WAChat[] chatToObject(JsonArray childrenArray) { - WAChat[] WAChats = new WAChat[childrenArray.size()]; + WAChat[] waChats = new WAChat[childrenArray.size()]; for(int i = 0; i < childrenArray.size(); i++) { JsonObject chatAttributes = childrenArray.get(i).getAsJsonArray().get(1).getAsJsonObject(); @@ -103,10 +103,10 @@ private static WAChat[] chatToObject(JsonArray childrenArray) { long lastInteraction = chatAttributes.get("t").getAsLong(); boolean muted = chatAttributes.get("mute").getAsBoolean(); - WAChats[i] = new WAChat(jid, name, unreadMessages, lastInteraction, muted); + waChats[i] = new WAChat(jid, name, unreadMessages, lastInteraction, muted); } - storedWAChats = WAChats; - return WAChats; + storedWAChats = waChats; + return waChats; } // Convert json message of the type "contacts" into WebChat diff --git a/src/main/java/icu/jnet/whatsjava/whatsapp/WABackendConnector.java b/src/main/java/icu/jnet/whatsjava/whatsapp/WABackendConnector.java index 4aacc86..b4c767f 100644 --- a/src/main/java/icu/jnet/whatsjava/whatsapp/WABackendConnector.java +++ b/src/main/java/icu/jnet/whatsjava/whatsapp/WABackendConnector.java @@ -152,16 +152,15 @@ private int initOrRestoreSession() { String challengeResponse = sendText(challengeRequest); loginStatus = Utils.encodeValidJson(challengeResponse).get("status").getAsInt(); - - // An error occurred during authentication - // Old session data is invalid so it gets deleted - if(loginStatus != 200) { - AuthCredentials.deletePreviousSession(credentialsPath); - disconnect(); - } } else { loginStatus = Utils.encodeValidJson(restoreResponse).get("status").getAsInt(); } + // An error occurred during authentication + // Old session data is invalid so it gets deleted + if(loginStatus != 200) { + AuthCredentials.deletePreviousSession(credentialsPath); + disconnect(); + } } listener.onReceiveLoginResponse(loginStatus); return loginStatus; @@ -216,14 +215,14 @@ private String waitForTextMessage(String... search) { } } } - Utils.waitMill(100); + Utils.waitMill(50); } } return null; } @Override - public void onTextMessage(WebSocket websocket, String message) throws Exception { + public void onTextMessage(WebSocket websocket, String message) { textMessageBuffer.add(message); } @@ -232,7 +231,7 @@ public void onBinaryMessage(WebSocket websocket, byte[] binaryMessage) throws Ex // Decrypt binary message byte[] decrypted = BinaryEncryption.decrypt(binaryMessage, auth.getEncryptionKeyPair()); - // Use protobuf to make messages of the type "message" human readable + // Use protobuf to make messages of the type "message" human-readable String decoded = new BinaryDecoder().decode(decrypted); textMessageBuffer.add(decoded); WAMessageParser.jsonToObjects(decoded);