From 9eb5c2a49d3388b6d19c1063ca9939cbab63c4a0 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 18 Aug 2014 18:48:57 +0200 Subject: [PATCH] Load roster before sending the initial presence SMACK-596 --- .../jivesoftware/smack/bosh/XMPPBOSHConnection.java | 13 ++++++++----- .../jivesoftware/smack/tcp/XMPPTCPConnection.java | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java index ba18c2734..798eb2aac 100644 --- a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java +++ b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java @@ -277,11 +277,6 @@ public class XMPPBOSHConnection extends XMPPConnection { } } - // Set presence to online. - if (config.isSendPresence()) { - sendPacket(new Presence(Presence.Type.available)); - } - // Indicate that we're now authenticated. authenticated = true; anonymous = false; @@ -296,6 +291,14 @@ public class XMPPBOSHConnection extends XMPPConnection { debugger.userHasLogged(user); } callConnectionAuthenticatedListener(); + + // Set presence to online. It is important that this is done after + // callConnectionAuthenticatedListener(), as this call will also + // eventually load the roster. And we should load the roster before we + // send the initial presence. + if (config.isSendPresence()) { + sendPacket(new Presence(Presence.Type.available)); + } } public void loginAnonymously() throws XMPPException, SmackException, IOException { diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 264140540..6d797eb7f 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -274,11 +274,6 @@ public class XMPPTCPConnection extends XMPPConnection { authenticated = true; anonymous = false; - // Set presence to online. - if (config.isSendPresence()) { - sendPacket(new Presence(Presence.Type.available)); - } - // Stores the authentication for future reconnection setLoginInfo(username, password, resource); @@ -290,6 +285,14 @@ public class XMPPTCPConnection extends XMPPConnection { debugger.userHasLogged(user); } callConnectionAuthenticatedListener(); + + // Set presence to online. It is important that this is done after + // callConnectionAuthenticatedListener(), as this call will also + // eventually load the roster. And we should load the roster before we + // send the initial presence. + if (config.isSendPresence()) { + sendPacket(new Presence(Presence.Type.available)); + } } @Override