Package org.jivesoftware.smackx.packet

Examples of org.jivesoftware.smackx.packet.DelayInformation


                        "class org.jivesoftware.smack.packet.Message")) {
                    Message m = (Message) packet;

                    if (m.getBody() != null) {
                       // System.out.println("Body is " + m.getBody());
                        DelayInformation inf = null;
                        try {
                            inf = (DelayInformation) packet.getExtension(
                                    "x", "jabber:x:delay");

View Full Code Here


                            "class org.jivesoftware.smack.packet.Message")) {
                        Message m = (Message) packet;

                        if (m.getBody() != null) {
                            System.out.println("Body is " + m.getBody());
                            DelayInformation inf = null;
                            try {
                                inf = (DelayInformation) packet.getExtension(
                                        "x", "jabber:x:delay");

                                // get offline message timestamp
View Full Code Here

                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
                formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
                stamp = formatter.parse(parser.getAttributeValue("", "stamp"));
            }
        }
        DelayInformation delayInformation = new DelayInformation(stamp);
        delayInformation.setFrom(parser.getAttributeValue("", "from"));
        delayInformation.setReason(parser.nextText());
        return delayInformation;
    }
View Full Code Here

                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
                formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
                stamp = formatter.parse(parser.getAttributeValue("", "stamp"));
            }
        }
        DelayInformation delayInformation = new DelayInformation(stamp);
        delayInformation.setFrom(parser.getAttributeValue("", "from"));
        delayInformation.setReason(parser.nextText());
        return delayInformation;
    }
View Full Code Here

        parent.getJavwerManager().getJRoster().getRoster().addRosterListener( rosterListener );
    }
   
    public void addMessage( Message message ) {
        String timeString = "";
        DelayInformation delay = (DelayInformation) message.getExtension( "x", "jabber:x:delay" );
        if( delay != null ) {
            DateFormat formater = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.MEDIUM );
            timeString = "[" + formater.format( delay.getStamp() ) + "] ";
        }
        if( message.getFrom().startsWith( user ) )
            addMessage( timeString + message.getBody(), JVW.MSG.CONTACT );
        else
            addMessage( timeString + message.getBody(), JVW.MSG.ME );
View Full Code Here

            Message msg;
            // Get first historic message
            msg = muc2.nextMessage(1000);
            assertNotNull("First message is null", msg);
            DelayInformation delay = (DelayInformation) msg.getExtension("x", "jabber:x:delay");
            assertNotNull("Message contains no delay information", delay);
            SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
            UTC_FORMAT.setTimeZone(TimeZone.getDefault());
            System.out.println(UTC_FORMAT.format(delay.getStamp()));

            assertEquals("Body of first message is incorrect", "Message 3", msg.getBody());
            // Try to get second historic message
            msg = muc2.nextMessage(1000);
            assertNull("Second message is not null", msg);
View Full Code Here

                stamp = new Date(0);
            }
        }
       
       
        DelayInformation delayInformation = new DelayInformation(stamp);
        delayInformation.setFrom(parser.getAttributeValue("", "from"));
        String reason = parser.nextText();

        /*
         * parser.nextText() returns empty string if there is no reason.
         * DelayInformation API specifies that null should be returned in that
         * case.
         */
        reason = "".equals(reason) ? null : reason;
        delayInformation.setReason(reason);
       
        return delayInformation;
    }
View Full Code Here

   
    public void processPacket(Packet packet)
    {
          EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
      ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
      DelayInformation delay = (DelayInformation)packet.getExtension("delay", "urn:xmpp:delay");
     
      // If there was no delay based on XEP-0203, then try XEP-0091 for backward compatibility
      if (delay == null)
      {
        delay = (DelayInformation)packet.getExtension("x", "jabber:x:delay");
      }
      ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), (List<Item>)itemsElem.getItems(), getSubscriptionIds(packet), (delay == null ? null : delay.getStamp()));
      listener.handlePublishedItems(eventItems);
    }
View Full Code Here

TOP

Related Classes of org.jivesoftware.smackx.packet.DelayInformation

Copyright © 2018 www.massapicom. 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.