Examples of LastActivity


Examples of com.valhalla.jbother.jabber.smack.LastActivity

    public void run() {
        if( dialog.cancelled ) return;

        XMPPConnection con = BuddyList.getInstance().getConnection();

        LastActivity request = new LastActivity();
        request.setType(IQ.Type.GET);
        request.setTo(dialog.getUser());

        // Create a packet collector to listen for a response.
        PacketCollector collector = con
                .createPacketCollector(new PacketIDFilter(request.getPacketID()));

        con.sendPacket(request);

        // Wait up to 5 seconds for a result.
        IQ result = (IQ) collector.nextResult(SmackConfiguration
                .getPacketReplyTimeout());
        if( dialog.cancelled ) return;

        if (result != null && result.getType() == IQ.Type.RESULT) {
            LastActivity t = (LastActivity) result;

            field.setText(t.showTime());
        } else
            field.setText("N/A");
        field.validate();
    }
View Full Code Here

Examples of org.jivesoftware.smackx.packet.LastActivity

        // Register a listener for a last activity query
        connection.addPacketListener(new PacketListener() {

            public void processPacket(Packet packet) {
                LastActivity message = new LastActivity();
                message.setType(IQ.Type.RESULT);
                message.setTo(packet.getFrom());
                message.setFrom(packet.getTo());
                message.setPacketID(packet.getPacketID());
                message.setLastActivity(getIdleTime());

                LastActivityManager.this.connection.sendPacket(message);
            }

        }, new AndFilter(new IQTypeFilter(IQ.Type.GET), new PacketTypeFilter(LastActivity.class)));
View Full Code Here

Examples of org.jivesoftware.smackx.packet.LastActivity

     * @return the LastActivity packet of the jid.
     * @throws XMPPException thrown if a server error has occured.
     */
    public static LastActivity getLastActivity(Connection con, String jid)
            throws XMPPException {
        LastActivity activity = new LastActivity();
        activity.setTo(jid);

        PacketCollector collector =
                con.createPacketCollector(new PacketIDFilter(activity.getPacketID()));
        con.sendPacket(activity);

        LastActivity response =
                (LastActivity) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

        // Cancel the collector.
        collector.cancel();
        if (response == null) {
            throw new XMPPException("No response from server on status set.");
        }
        if (response.getError() != null) {
            throw new XMPPException(response.getError());
        }
        return response;
  }
View Full Code Here

Examples of org.jivesoftware.smackx.packet.LastActivity

    } catch (InterruptedException e) {
      e.printStackTrace();
      fail("Thread sleep interrupted");
    }

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

    // Asserts that the last activity packet was received
    assertNotNull("No last activity packet", lastActivity);
    // Asserts that there is at least a 1 second of idle time
        assertTrue(
                "The last activity idle time is less than expected: " + lastActivity.getIdleTime(),
                lastActivity.getIdleTime() >= 1);
    }
View Full Code Here

Examples of org.jivesoftware.smackx.packet.LastActivity

   * 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);
    }
View Full Code Here

Examples of org.jivesoftware.smackx.packet.LastActivity

   * 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);
    }
View Full Code Here

Examples of org.jivesoftware.smackx.packet.LastActivity

        // Register a listener for a last activity query
        connection.addPacketListener(new PacketListener() {

            public void processPacket(Packet packet) {
                LastActivity message = new LastActivity();
                message.setType(IQ.Type.RESULT);
                message.setTo(packet.getFrom());
                message.setFrom(packet.getTo());
                message.setPacketID(packet.getPacketID());
                message.setLastActivity(getIdleTime());

                LastActivityManager.this.connection.sendPacket(message);
            }

        }, new AndFilter(new IQTypeFilter(IQ.Type.GET), new PacketTypeFilter(LastActivity.class)));
View Full Code Here

Examples of org.jivesoftware.smackx.packet.LastActivity

     * @return the LastActivity packet of the jid.
     * @throws XMPPException thrown if a server error has occured.
     */
    public static LastActivity getLastActivity(XMPPConnection con, String jid)
            throws XMPPException {
        LastActivity activity = new LastActivity();
        activity.setTo(jid);

        PacketCollector collector =
                con.createPacketCollector(new PacketIDFilter(activity.getPacketID()));
        con.sendPacket(activity);

        LastActivity response =
                (LastActivity) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

        // Cancel the collector.
        collector.cancel();
        if (response == null) {
            throw new XMPPException("No response from server on status set.");
        }
        if (response.getError() != null) {
            throw new XMPPException(response.getError());
        }
        return response;
  }
View Full Code Here

Examples of org.jivesoftware.smackx.packet.LastActivity

    } catch (InterruptedException e) {
      e.printStackTrace();
      fail("Thread sleep interrupted");
    }

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

    // Asserts that the last activity packet was received
    assertNotNull("No last activity packet", lastActivity);
    // Asserts that there is at least a 1 second of idle time
        assertTrue(
                "The last activity idle time is less than expected: " + lastActivity.getIdleTime(),
                lastActivity.getIdleTime() >= 1);
    }
View Full Code Here

Examples of org.jivesoftware.smackx.packet.LastActivity

   * 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);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.