powered by Jive Software

How to change the login status

Hi all,

After call xmppConn.login(username, password, resource), the login user always appears to be online status. Is there a way to configure the default login status as ‘OFFLINE’ or ‘INVISABLE’?

Thanks,

Is this the way how I should do it?

xmppConn.login(username, password, resource);
xmppConn.sendPacket(new Presence(Presence.Type.unavailable));

But this still sends an unavailable IQ message to all the entries in my roster list. Is there a way we can absolutely stop acknolwdge people that this login info?

Hello,

You can tell smack not to send an initial presence packet by doing the following:

xmppConn.login(username, password, resource, false);

Hope that helps,

Ryan

Ryan, thanks for your response.

After tried to login using that way, I still received XMPP presence messages.

Is there a way that we can absolutely stop sending out this presence message to the entry in the roster when monitor logins to XMPP server?

Hello,

Which version of smack are you using? When I tested it using 3.0.4 I didn’t see any presence packets being sent. Below is my sample code:

public class Login {
   private XMPPConnection connection;    public static void main(String[] args) {
      new Login();
   }    private Login() {
      XMPPConnection.DEBUG_ENABLED = true;
      connection = new XMPPConnection("10.160.36.102");
      try {
         connection.connect();
         connection.login("jill", "1", "smack", false);
      }
      catch (XMPPException e) {
         e.printStackTrace();
         System.out.println(e.getXMPPError());
      }
   }
}

and here is all the xml that is being sent:

<stream:stream to="10.160.36.102" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
<stream:stream to="10.160.36.102" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
<auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">AGppbGwAMQ==</auth>
<stream:stream to="10.160.36.102" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
<iq id="Tw8XR-0" type="set"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>smack</resource></bind></iq>
<iq id="Tw8XR-1" type="set"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq>
<iq id="Tw8XR-2" type="get"><query xmlns="jabber:iq:roster"></query></iq>

Regards,

Ryan

Ryan, I think you are right. The presence packets were forwarded by XMPP server, but not from the smack package.