congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
StanzaListener.processStanza
Code IndexAdd Tabnine to your IDE (free)

How to use
processStanza
method
in
org.jivesoftware.smack.StanzaListener

Best Java code snippets using org.jivesoftware.smack.StanzaListener.processStanza (Showing top 20 results out of 315)

origin: igniterealtime/Smack

/**
 * Process IQ stanza.
 * @param data
 * @throws NotConnectedException
 * @throws InterruptedException
 * @throws NotLoggedInException
 */
public void processIQPacket(Data data) throws NotConnectedException, InterruptedException, NotLoggedInException {
  inputStream.dataPacketListener.processStanza(data);
}
origin: igniterealtime/Smack

  @Override
  public void run() {
    try {
      listener.processStanza(packet);
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, "Exception in async packet listener", e);
    }
  }
});
origin: igniterealtime/Smack

  @Override
  public void run() {
    for (StanzaListener listener : listenersToNotify) {
      try {
        listener.processStanza(packet);
      }
      catch (Exception e) {
        LOGGER.log(Level.WARNING, "Sending listener threw exception", e);
        continue;
      }
    }
  }
});
origin: igniterealtime/Smack

  @Override
  public void processStanza(Stanza packet) throws NotConnectedException, InterruptedException, NotLoggedInException {
    try {
      callback.processStanza(packet);
    } finally {
      removeSyncStanzaListener(this);
    }
  }
};
origin: igniterealtime/Smack

  @Override
  public void run() {
    // As listeners are able to remove themselves and because the timepoint where it is decided to invoke a
    // listener is a different timepoint where the listener is actually invoked (here), we have to check
    // again if the listener is still active.
    Iterator<StanzaListener> it = listenersToNotify.iterator();
    synchronized (syncRecvListeners) {
      while (it.hasNext()) {
        StanzaListener stanzaListener = it.next();
        if (!syncRecvListeners.containsKey(stanzaListener)) {
          // The listener was removed from syncRecvListener, also remove him from listenersToNotify.
          it.remove();
        }
      }
    }
    for (StanzaListener listener : listenersToNotify) {
      try {
        listener.processStanza(packet);
      } catch (NotConnectedException e) {
        LOGGER.log(Level.WARNING, "Got not connected exception, aborting", e);
        break;
      } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Exception in packet listener", e);
      }
    }
  }
});
origin: igniterealtime/Smack

  @Override
  public void run() {
    for (Stanza ackedStanza : ackedStanzas) {
      for (StanzaListener listener : stanzaAcknowledgedListeners) {
        try {
          listener.processStanza(ackedStanza);
        }
        catch (InterruptedException | NotConnectedException | NotLoggedInException e) {
          LOGGER.log(Level.FINER, "Received exception", e);
        }
      }
      String id = ackedStanza.getStanzaId();
      if (StringUtils.isNullOrEmpty(id)) {
        continue;
      }
      StanzaListener listener = stanzaIdAcknowledgedListeners.remove(id);
      if (listener != null) {
        try {
          listener.processStanza(ackedStanza);
        }
        catch (InterruptedException | NotConnectedException | NotLoggedInException e) {
          LOGGER.log(Level.FINER, "Received exception", e);
        }
      }
    }
  }
});
origin: igniterealtime/Smack

/**
 * Process interceptors. Interceptors may modify the stanza that is about to be sent.
 * Since the thread that requested to send the stanza will invoke all interceptors, it
 * is important that interceptors perform their work as soon as possible so that the
 * thread does not remain blocked for a long period.
 *
 * @param packet the stanza that is going to be sent to the server
 */
private void firePacketInterceptors(Stanza packet) {
  List<StanzaListener> interceptorsToInvoke = new LinkedList<>();
  synchronized (interceptors) {
    for (InterceptorWrapper interceptorWrapper : interceptors.values()) {
      if (interceptorWrapper.filterMatches(packet)) {
        interceptorsToInvoke.add(interceptorWrapper.getInterceptor());
      }
    }
  }
  for (StanzaListener interceptor : interceptorsToInvoke) {
    try {
      interceptor.processStanza(packet);
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, "Packet interceptor threw exception", e);
    }
  }
}
origin: igniterealtime/Smack

listener.processStanza(data);
origin: igniterealtime/Smack

listener.processStanza(data);
origin: igniterealtime/Smack

DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data);
Data data = new Data(dpe);
listener.processStanza(data);
origin: igniterealtime/Smack

Message dataMessage = new Message();
dataMessage.addExtension(dpe);
listener.processStanza(dataMessage);
origin: igniterealtime/Smack

Message dataMessage = new Message();
dataMessage.addExtension(dpe);
listener.processStanza(dataMessage);
origin: igniterealtime/Smack

DataPacketExtension dpe = new DataPacketExtension(sessionID, i, base64Data);
Data data = new Data(dpe);
listener.processStanza(data);
origin: igniterealtime/Smack

DataPacketExtension dpe = new DataPacketExtension(sessionID, i, base64Data);
Data data = new Data(dpe);
listener.processStanza(data);
origin: igniterealtime/Smack

listener.processStanza(dataMessage);
origin: igniterealtime/Smack

listener.processStanza(data1);
listener.processStanza(data2);
origin: igniterealtime/Smack

listener.processStanza(data);
origin: igniterealtime/Smack

/**
 * Valid data packets should be confirmed.
 *
 * @throws Exception should not happen
 */
@Test
public void shouldConfirmReceivedDataPacket() throws Exception {
  // verify data packet confirmation is of type RESULT
  protocol.addResponse(null, Verification.requestTypeRESULT);
  InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
          initiatorJID);
  InputStream inputStream = session.getInputStream();
  StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
  String base64Data = Base64.encode("Data");
  DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data);
  Data data = new Data(dpe);
  listener.processStanza(data);
  protocol.verifyAll();
}
origin: igniterealtime/Smack

/**
 * If the data stanza contains invalid Base64 encoding an 'bad-request' error should be
 * returned. See XEP-0047 Section 2.2.
 *
 * @throws Exception should not happen
 */
@Test
public void shouldReplyWithErrorIfDataIsInvalid() throws Exception {
  // verify reply to invalid data packet is an error
  protocol.addResponse(null, Verification.requestTypeERROR, new Verification<IQ, IQ>() {
    @Override
    public void verify(IQ request, IQ response) {
      assertEquals(StanzaError.Condition.bad_request,
              request.getError().getCondition());
    }
  });
  // get IBB sessions data packet listener
  InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
          initiatorJID);
  InputStream inputStream = session.getInputStream();
  StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
  // build data packets
  DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, "AA=BB");
  Data data = new Data(dpe);
  // notify listener
  listener.processStanza(data);
  protocol.verifyAll();
}
origin: spring-projects/spring-integration

@Test
public void testInboundAdapterUsageWithHeaderMapper() throws Exception {
  XMPPConnection xmppConnection = Mockito.mock(XMPPConnection.class);
  ChatMessageListeningEndpoint adapter = context.getBean("xmppInboundAdapter", ChatMessageListeningEndpoint.class);
  Field xmppConnectionField = ReflectionUtils.findField(ChatMessageListeningEndpoint.class, "xmppConnection");
  xmppConnectionField.setAccessible(true);
  ReflectionUtils.setField(xmppConnectionField, adapter, xmppConnection);
  StanzaListener stanzaListener = TestUtils.getPropertyValue(adapter, "stanzaListener", StanzaListener.class);
  Message message = new Message();
  message.setBody("hello");
  message.setTo(JidCreate.from("oleg"));
  JivePropertiesManager.addProperty(message, "foo", "foo");
  JivePropertiesManager.addProperty(message, "bar", "bar");
  stanzaListener.processStanza(message);
  org.springframework.messaging.Message<?> siMessage = xmppInbound.receive(0);
  assertEquals("foo", siMessage.getHeaders().get("foo"));
  assertEquals("oleg", siMessage.getHeaders().get("xmpp_to"));
}
org.jivesoftware.smackStanzaListenerprocessStanza

Javadoc

Process the next stanza sent to this stanza listener.

If this listener is synchronous, then a single thread is responsible for invoking all listeners, so it's very important that implementations of this method not block for any extended period of time.

Popular methods of StanzaListener

  • processPacket

Popular in Java

  • Making http requests using okhttp
  • setScale (BigDecimal)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • findViewById (Activity)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now