reworked that loop that iterates over various servers
This commit is contained in:
parent
a85bba0010
commit
20ec9ff2c6
|
@ -257,10 +257,8 @@ public class XmppConnection implements Runnable {
|
|||
} else {
|
||||
final Bundle result = DNSHelper.getSRVRecord(account.getServer(), mXmppConnectionService);
|
||||
final ArrayList<Parcelable>values = result.getParcelableArrayList("values");
|
||||
int i = 0;
|
||||
boolean socketError = true;
|
||||
while (socketError && values.size() > i) {
|
||||
final Bundle namePort = (Bundle) values.get(i);
|
||||
for(Iterator<Parcelable> iterator = values.iterator(); iterator.hasNext();) {
|
||||
final Bundle namePort = (Bundle) iterator.next();
|
||||
try {
|
||||
String srvRecordServer;
|
||||
try {
|
||||
|
@ -285,22 +283,18 @@ public class XmppConnection implements Runnable {
|
|||
}
|
||||
socket = new Socket();
|
||||
socket.connect(addr, Config.SOCKET_TIMEOUT * 1000);
|
||||
socketError = false;
|
||||
tagWriter.setOutputStream(socket.getOutputStream());
|
||||
tagReader.setInputStream(socket.getInputStream());
|
||||
tagWriter.beginDocument();
|
||||
sendStartStream();
|
||||
} catch (final Throwable e) {
|
||||
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage() +"("+e.getClass().getName()+")");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (socketError) {
|
||||
if (!iterator.hasNext()) {
|
||||
throw new UnknownHostException();
|
||||
}
|
||||
}
|
||||
final OutputStream out = socket.getOutputStream();
|
||||
tagWriter.setOutputStream(out);
|
||||
final InputStream in = socket.getInputStream();
|
||||
tagReader.setInputStream(in);
|
||||
tagWriter.beginDocument();
|
||||
sendStartStream();
|
||||
}
|
||||
}
|
||||
Tag nextTag;
|
||||
while ((nextTag = tagReader.readTag()) != null) {
|
||||
if (nextTag.isStart("stream")) {
|
||||
|
|
Loading…
Reference in a new issue