Beispiel #1
0
    @SuppressWarnings({"rawtypes", "unchecked"})
    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);
    }
Beispiel #2
0
    public void processPacket(Packet packet) {
      EventElement event =
          (EventElement) packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());

      List<PacketExtension> extList = event.getExtensions();

      if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName())) {
        listener.handlePurge();
      } else {
        ItemsExtension itemsElem = (ItemsExtension) event.getEvent();
        @SuppressWarnings("unchecked")
        Collection<RetractItem> pubItems = (Collection<RetractItem>) itemsElem.getItems();
        List<String> items = new ArrayList<String>(pubItems.size());

        for (RetractItem item : pubItems) {
          items.add(item.getId());
        }

        ItemDeleteEvent eventItems =
            new ItemDeleteEvent(itemsElem.getNode(), items, getSubscriptionIds(packet));
        listener.handleDeletedItems(eventItems);
      }
    }