In Spark, when a user connects from another client, you get a message telling you you’ve been disconnected because someone else connected with your username. We’re trying to do this same functionallity on a Flex client using Xiff 3.0 beta. We have a listener on DisconnectionEvent.DISCONNECT:
xmppConnection.addEventListener(DisconnectionEvent.DISCONNECT, onDisconnect);
But the event doesn’t provide information as to why we’ve been disconnected.Spark uses the following code to catch the accounts conflict disconnection (Code from /src/java/org/jivesoftware/spark/ui/ContactList.java on Spark source):
Code:
public void connectionClosedOnError(final Exception ex) {
String errorMessage = Res.getString("message.disconnected.error");
if (ex != null && ex instanceof XMPPException) {
XMPPException xmppEx = (XMPPException)ex;
StreamError error = xmppEx.getStreamError();
String reason = error.getCode();
if ("conflict".equals(reason)) {
errorMessage = Res.getString("message.disconnected.conflict.error");
}
else if ("system-shutdown".equals(reason)) {
errorMessage = Res.getString("message.disconnected.shutdown");
}
else {
errorMessage = Res.getString("message.general.error", reason);
}
}
final String message = errorMessage;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
retryPanel.setClosedOnError(true);
reconnect(message);
}
});
}
Is there a way to know we’ve been disconnected because someone else has logged in with our user with XIFF? Or is this something that should be implemented from scratch on Xiff?