If the Server want to get the presence status of a user, this is my method:
- createConnection: XMPPConnection cnn = XMPPConnection(“192.168.1.111:9090”); cnn.connecy();
First of all, 9090 is usually the port for the admin console, not for XMPP traffic. The default for XMPP clients is 5222 and 5223 (secure) respectively.
- login: cnn.login(“aaa”, “bbb”);
- getRoster: Roster roster = cnn.getRoster();
- gePresnce; Presence ps = roster.getPresence(“jack”) the parameter “String user” is user’s JID or user’s nickname? please tell me
The username, never the nickname, as it doesn’t need to be unique. I use
- judge Pesence; ps.getType == Presence.Type.onvailible
// take care of users with multiple resources
// presence value for the user with the highest priority and availability.
String user = presence.getFrom();
String userJID = StringUtils.parseBareAddress(user);
Presence bestPresence =lRoster.getPresence(user);
Besides Presence.Type.available you can check Presence.Mode for availability.
Is my method right? Please tell me, Thanks
Please do have a look at the JavaDocs of smack.