Improving reconnection logic.

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@7697 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2007-03-25 23:26:46 +00:00
committed by derek
parent 09fe7e7e88
commit bb389d64ce
2 changed files with 15 additions and 0 deletions

View File

@ -261,6 +261,11 @@ public final class ContactList extends JPanel implements ActionListener, Contact
* @param presence the user to update. * @param presence the user to update.
*/ */
private void updateUserPresence(Presence presence) throws Exception { private void updateUserPresence(Presence presence) throws Exception {
if(presence.getError() != null){
// We ignore this.
return;
}
final Roster roster = SparkManager.getConnection().getRoster(); final Roster roster = SparkManager.getConnection().getRoster();
final String bareJID = StringUtils.parseBareAddress(presence.getFrom()); final String bareJID = StringUtils.parseBareAddress(presence.getFrom());
@ -272,6 +277,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
// If online, check to see if they are in the offline group. // If online, check to see if they are in the offline group.
// If so, remove from offline group and add to all groups they // If so, remove from offline group and add to all groups they
// belong to. // belong to.
if (presence.getType() == Presence.Type.available && offlineGroup.getContactItemByJID(bareJID) != null || (presence.getFrom().indexOf("workgroup.") != -1)) { if (presence.getType() == Presence.Type.available && offlineGroup.getContactItemByJID(bareJID) != null || (presence.getFrom().indexOf("workgroup.") != -1)) {
changeOfflineToOnline(bareJID, entry, presence); changeOfflineToOnline(bareJID, entry, presence);
} }

View File

@ -41,6 +41,8 @@ public class RetryPanel extends JPanel {
private RolloverButton retryButton; private RolloverButton retryButton;
private boolean closedOnError = false; private boolean closedOnError = false;
private boolean connecting;
/** /**
* Construct the RetryPanel. * Construct the RetryPanel.
*/ */
@ -70,6 +72,7 @@ public class RetryPanel extends JPanel {
} }
private void attemptReconnection() { private void attemptReconnection() {
connecting = true;
retryButton.setText("Attempting..."); retryButton.setText("Attempting...");
retryButton.setEnabled(false); retryButton.setEnabled(false);
@ -83,6 +86,7 @@ public class RetryPanel extends JPanel {
} }
private void reconnect() { private void reconnect() {
try { try {
if (closedOnError) { if (closedOnError) {
SparkManager.getConnection().connect(); SparkManager.getConnection().connect();
@ -95,6 +99,8 @@ public class RetryPanel extends JPanel {
ex.printStackTrace(); ex.printStackTrace();
} }
connecting = false;
retryButton.setEnabled(true); retryButton.setEnabled(true);
retryButton.setText("Reconnect...."); retryButton.setText("Reconnect....");
} }
@ -133,6 +139,9 @@ public class RetryPanel extends JPanel {
* @param text the text to display on the reconnect button. * @param text the text to display on the reconnect button.
*/ */
protected void setReconnectText(String text) { protected void setReconnectText(String text) {
if (connecting) {
return;
}
retryButton.setVisible(true); retryButton.setVisible(true);
retryButton.setText(text); retryButton.setText(text);
} }