1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-23 04:22:05 +01:00

Last Activity will convert to bare jid if resource found.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2821 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro 2005-09-14 14:43:04 +00:00 committed by derek
parent 44d3b0a08b
commit e4f13bd49c

View file

@ -25,6 +25,7 @@ import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.filter.PacketIDFilter; import org.jivesoftware.smack.filter.PacketIDFilter;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
@ -76,7 +77,7 @@ public class LastActivity extends IQ {
* *
* @return the number of seconds that have passed since the user last logged out. * @return the number of seconds that have passed since the user last logged out.
*/ */
public long getLastActivity() { public long getIdleTime() {
return lastActivity; return lastActivity;
} }
@ -135,6 +136,7 @@ public class LastActivity extends IQ {
*/ */
public static LastActivity getLastActivity(XMPPConnection con, String jid) throws XMPPException { public static LastActivity getLastActivity(XMPPConnection con, String jid) throws XMPPException {
LastActivity activity = new LastActivity(); LastActivity activity = new LastActivity();
jid = StringUtils.parseBareAddress(jid);
activity.setTo(jid); activity.setTo(jid);
PacketCollector collector = con.createPacketCollector(new PacketIDFilter(activity.getPacketID())); PacketCollector collector = con.createPacketCollector(new PacketIDFilter(activity.getPacketID()));
@ -152,4 +154,12 @@ public class LastActivity extends IQ {
} }
return response; return response;
} }
public static void main(String args[]) throws Exception{
XMPPConnection con = new XMPPConnection("jivesoftware.com");
con.login("derek", "test");
LastActivity active = LastActivity.getLastActivity(con, "bruce@jivesoftware.com/Home");
System.out.println(active);
}
} }