Esempio n. 1
0
    public boolean accept(Packet packet) {
      if (!(packet instanceof Message)) return false;

      EventElement event =
          (EventElement) packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());

      if (event == null) return false;

      NodeExtension embedEvent = event.getEvent();

      if (embedEvent == null) return false;

      if (embedEvent.getElementName().equals(firstElement)) {
        if (!embedEvent.getNode().equals(getId())) return false;

        if (secondElement == null) return true;

        if (embedEvent instanceof EmbeddedPacketExtension) {
          List<PacketExtension> secondLevelList =
              ((EmbeddedPacketExtension) embedEvent).getExtensions();

          if (secondLevelList.size() > 0
              && secondLevelList.get(0).getElementName().equals(secondElement)) return true;
        }
      }
      return false;
    }
Esempio n. 2
0
  /**
   * Creates an instant node, if supported.
   *
   * @return The node that was created
   * @exception XMPPException
   */
  public Node createNode() throws XMPPException {
    PubSub reply = (PubSub) sendPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.CREATE));
    NodeExtension elem =
        (NodeExtension) reply.getExtension("create", PubSubNamespace.BASIC.getXmlns());

    Node newNode = new Node(con, elem.getNode());
    newNode.setTo(to);
    nodeMap.put(newNode.getId(), newNode);

    return newNode;
  }