Java 类org.jivesoftware.smackx.packet.LastActivity 实例源码

项目:Smack    文件:LastActivityManagerTest.java   
/**
 * This is a test to check if a LastActivity request for last logged out
 * lapsed time is answered and correct
 */
public void testLastLoggedOut() {
    TCPConnection conn0 = getConnection(0);

    LastActivity lastActivity = null;
    try {
        lastActivity = LastActivityManager.getLastActivity(conn0, getBareJID(1));
    } catch (XMPPException e) {
        e.printStackTrace();
        fail("An error occurred requesting the Last Activity");
    }

    assertNotNull("No last activity packet", lastActivity);
       assertTrue("The last activity idle time should be 0 since the user is logged in: " +
               lastActivity.getIdleTime(), lastActivity.getIdleTime() == 0);
   }
项目:Smack    文件:LastActivityManagerTest.java   
/**
 * This is a test to check if a LastActivity request for server uptime
 * is answered and correct
 */
public void testServerUptime() {
    TCPConnection conn0 = getConnection(0);

    LastActivity lastActivity = null;
    try {
        lastActivity = LastActivityManager.getLastActivity(conn0, getHost());
    } catch (XMPPException e) {
        if (e.getXMPPError().getCode() == 403) {
            //The test can not be done since the host do not allow this kind of request
            return;
        }
        e.printStackTrace();
        fail("An error occurred requesting the Last Activity");
    }

    assertNotNull("No last activity packet", lastActivity);
       assertTrue("The last activity idle time should be greater than 0 : " +
               lastActivity.getIdleTime(), lastActivity.getIdleTime() > 0);
   }
项目:java-bells    文件:LastActivityManagerTest.java   
/**
 * This is a test to check if a LastActivity request for last logged out
 * lapsed time is answered and correct
 */
public void testLastLoggedOut() {
    XMPPConnection conn0 = getConnection(0);

    LastActivity lastActivity = null;
    try {
        lastActivity = LastActivityManager.getLastActivity(conn0, getBareJID(1));
    } catch (XMPPException e) {
        e.printStackTrace();
        fail("An error occurred requesting the Last Activity");
    }

    assertNotNull("No last activity packet", lastActivity);
       assertTrue("The last activity idle time should be 0 since the user is logged in: " +
               lastActivity.getIdleTime(), lastActivity.getIdleTime() == 0);
   }
项目:java-bells    文件:LastActivityManagerTest.java   
/**
 * This is a test to check if a LastActivity request for server uptime
 * is answered and correct
 */
public void testServerUptime() {
    XMPPConnection conn0 = getConnection(0);

    LastActivity lastActivity = null;
    try {
        lastActivity = LastActivityManager.getLastActivity(conn0, getHost());
    } catch (XMPPException e) {
        if (e.getXMPPError().getCode() == 403) {
            //The test can not be done since the host do not allow this kind of request
            return;
        }
        e.printStackTrace();
        fail("An error occurred requesting the Last Activity");
    }

    assertNotNull("No last activity packet", lastActivity);
       assertTrue("The last activity idle time should be greater than 0 : " +
               lastActivity.getIdleTime(), lastActivity.getIdleTime() > 0);
   }
项目:androidPN-client.    文件:LastActivityManager.java   
/**
 * Returns true if Last Activity (XEP-0012) is supported by a given JID
 * 
 * @param connection the connection to be used
 * @param jid a JID to be tested for Last Activity support
 * @return true if Last Activity is supported, otherwise false
 */
public static boolean isLastActivitySupported(Connection connection, String jid) {
    try {
        DiscoverInfo result =
            ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(jid);
        return result.containsFeature(LastActivity.NAMESPACE);
    }
    catch (XMPPException e) {
        return false;
    }
}
项目:java-bells    文件:LastActivityManager.java   
/**
 * Returns true if Last Activity (XEP-0012) is supported by a given JID
 * 
 * @param connection the connection to be used
 * @param jid a JID to be tested for Last Activity support
 * @return true if Last Activity is supported, otherwise false
 */
public static boolean isLastActivitySupported(Connection connection, String jid) {
    try {
        DiscoverInfo result =
            ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(jid);
        return result.containsFeature(LastActivity.NAMESPACE);
    }
    catch (XMPPException e) {
        return false;
    }
}