Ejemplo n.º 1
0
  /** Creates a destination for a service that receives XMPP messages. */
  public Destination getDestination(EndpointInfo endpointInfo) throws IOException {
    // The node name is the full name of the service.
    String nodeName = endpointInfo.getService().getName().toString();
    pepProvider.registerPEPParserExtension(nodeName, soapProvider);

    PEPDestination dest = new PEPDestination(endpointInfo);

    try {
      XMPPConnection conn = destinationConnectionFactory.login(endpointInfo);

      // Advertise interest in receiving information.
      ServiceDiscoveryManager disco = ServiceDiscoveryManager.getInstanceFor(conn);
      disco.addFeature(nodeName + "+notify");

      // Create destination.
      dest.setXmppConnection(conn);
      conn.addPacketListener(
          dest, new PacketExtensionFilter("event", "http://jabber.org/protocol/pubsub#event"));

    } catch (XMPPException e) {
      throw new IOException(e);
    }

    return dest;
  }
Ejemplo n.º 2
0
  /**
   * Creates a conduit for a client that all share a single XMPP connection. The connection is
   * shared via the bus.
   */
  @Override
  public Conduit getConduit(EndpointInfo endpointInfo, EndpointReferenceType endpointType)
      throws IOException {

    String nodeName = endpointInfo.getInterface().getName().toString();
    pepProvider.registerPEPParserExtension(nodeName, soapProvider);

    try {
      XMPPConnection conn = conduitConnectionFactory.login(endpointInfo);

      PEPManager mgr = new PEPManager(conn);
      PEPClientConduit conduit = new PEPClientConduit(endpointType, mgr, nodeName);
      conduit.setXmppConnection(conn);

      return conduit;

    } catch (XMPPException e) {
      throw new IOException(e);
    }
  }