rename resource on bind conflict

This commit is contained in:
Daniel Gultsch 2017-05-25 14:40:59 +02:00
parent fe29b51290
commit 3ece613a5d

View file

@ -1044,7 +1044,13 @@ public class XmppConnection implements Runnable {
} else { } else {
Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure (" + packet.toString()); Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure (" + packet.toString());
} }
account.setResource(account.getResource().split("\\.")[0]); final Element error = packet.findChild("error");
final String resource = account.getResource().split("\\.")[0];
if (packet.getType() == IqPacket.TYPE.ERROR && error != null && error.hasChild("conflict")) {
account.setResource(resource + "." + nextRandomId());
} else {
account.setResource(resource);
}
throw new StateChangingError(Account.State.BIND_FAILURE); throw new StateChangingError(Account.State.BIND_FAILURE);
} }
}); });