1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 18:59:41 +02:00

Better threading logic when getting a roster. Also avoid loading LiteDebugger explicitly as an attempted fix for SMACK-7.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2470 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2005-03-30 01:53:51 +00:00 committed by matt
parent 92869fa583
commit fb22583ea7
2 changed files with 54 additions and 27 deletions

View file

@ -418,20 +418,27 @@ public class XMPPConnection {
return null;
}
// If this is the first time the user has asked for the roster after calling
// login, we want to wait up to 2 seconds for the server to send back the
// user's roster. This behavior shields API users from having to worry about the
// fact that roster operations are asynchronous, although they'll still have to
// listen for changes to the roster. Note: because of this waiting logic, internal
// login, we want to wait for the server to send back the user's roster. This
// behavior shields API users from having to worry about the fact that roster
// operations are asynchronous, although they'll still have to listen for
// changes to the roster. Note: because of this waiting logic, internal
// Smack code should be wary about calling the getRoster method, and may need to
// access the roster object directly.
int elapsed = 0;
while (!roster.rosterInitialized && elapsed <= 2000) {
if (!roster.rosterInitialized) {
try {
Thread.sleep(500);
synchronized (roster) {
long waitTime = SmackConfiguration.getPacketReplyTimeout();
long start = System.currentTimeMillis();
while (!roster.rosterInitialized) {
if (waitTime <= 0) {
break;
}
roster.wait(waitTime);
waitTime -= System.currentTimeMillis() - start;
}
}
}
catch (Exception e) {
}
elapsed += 500;
catch (InterruptedException ie) { }
}
return roster;
}
@ -724,7 +731,12 @@ public class XMPPConnection {
Class.forName("org.jivesoftware.smackx.debugger.EnhancedDebugger");
}
catch (Exception ex) {
debuggerClass = LiteDebugger.class;
try {
debuggerClass = Class.forName("org.jivesoftware.smack.debugger.LiteDebugger");
}
catch (Exception ex2) {
ex2.printStackTrace();
}
}
}
// Create a new debugger instance. If an exception occurs then disable the debugging