Skip to content

Commit

Permalink
Slight code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
code-irisnk committed Mar 7, 2024
1 parent 3c9f921 commit 4555055
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .idea/runConfigurations/SimpleXMPPClient.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/main/java/team/elrant/bubbles/xmpp/ConnectedUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* It describes how the app's current user should connect, behave, send messages, etc.
*/
public class ConnectedUser extends User {
private String password;
private final String password;
private Roster roster;
private AbstractXMPPConnection connection = null; // When accessing this property, make sure it's not null
// (or just run InitializeConnection first)
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/team/elrant/bubbles/xmpp/SimpleXMPPClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ public static void main(String[] args) {
String password = "";
String serviceName = "elrant.team";

ConnectedUser user = null;
ConnectedUser connectedUser = null;
try {
user = new ConnectedUser(username, password, serviceName);
connectedUser = new ConnectedUser(username, password, serviceName);
System.out.println("Connection established!");
} catch (Exception e) {
e.printStackTrace(); // Replace with more robust error handling in the future
}

try {
user.addIncomingMessageListener(); /* Print any incoming messages */
Thread.sleep(10000); /* Sleep for 10 seconds */
if (connectedUser != null && connectedUser.isLoggedIn()) {
connectedUser.addIncomingMessageListener(); /* Print any incoming messages */
Thread.sleep(10000); /* Sleep for 10 seconds */
connectedUser.disconnect();
}
} catch (InterruptedException e) {
e.printStackTrace(); // Replace with more robust error handling in the future
}
user.disconnect();
}
}
3 changes: 0 additions & 3 deletions src/main/java/team/elrant/bubbles/xmpp/User.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package team.elrant.bubbles.xmpp;

import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
Expand Down

0 comments on commit 4555055

Please sign in to comment.