/** * Polls for and returns the next message. * * @return the next message if one is immediately available */ public Message pollMessage() { return messageCollector.pollResult(); }
/** * Polls for and returns the next message, or <tt>null</tt> if there isn't * a message immediately available. This method provides significantly different * functionalty than the {@link #nextMessage()} method since it's non-blocking. * In other words, the method call will always return immediately, whereas the * nextMessage method will return only when a message is available (or after * a specific timeout). * * @return the next message if one is immediately available and * <tt>null</tt> otherwise. * @throws MucNotJoinedException */ public Message pollMessage() throws MucNotJoinedException { if (messageCollector == null) { throw new MucNotJoinedException(this); } return messageCollector.pollResult(); }
/** * Polls to see if a stanza is currently available and returns it, or * immediately returns <tt>null</tt> if no packets are currently in the * result queue. * <p> * Throws an XMPPErrorException in case the polled stanzas did contain an XMPPError. * </p> * * @param <P> type of the result stanza. * @return the next available packet. * @throws XMPPErrorException in case an error response. */ public <P extends Stanza> P pollResultOrThrow() throws XMPPErrorException { P result = pollResult(); if (result != null) { XMPPErrorException.ifHasErrorThenThrow(result); } return result; }
messages = new ArrayList<>(messageCollector.getCollectedCount()); Message message; while ((message = messageCollector.pollResult()) != null) { messages.add(message);
List<IoTFieldsExtension> res = new ArrayList<>(collectedCount); for (int i = 0; i < collectedCount; i++) { Message message = dataCollector.pollResult(); IoTFieldsExtension iotFieldsExtension = IoTFieldsExtension.from(message); res.add(iotFieldsExtension);
/** * Polls for and returns the next message. * * @return the next message if one is immediately available */ public Message pollMessage() { return messageCollector.pollResult(); }
/** * Polls to see if a stanza is currently available and returns it, or * immediately returns <tt>null</tt> if no packets are currently in the * result queue. * <p> * Throws an XMPPErrorException in case the polled stanzas did contain an XMPPError. * </p> * * @param <P> type of the result stanza. * @return the next available packet. * @throws XMPPErrorException in case an error response. */ public <P extends Stanza> P pollResultOrThrow() throws XMPPErrorException { P result = pollResult(); if (result != null) { XMPPErrorException.ifHasErrorThenThrow(result); } return result; }
List<IoTFieldsExtension> res = new ArrayList<>(collectedCount); for (int i = 0; i < collectedCount; i++) { Message message = dataCollector.pollResult(); IoTFieldsExtension iotFieldsExtension = IoTFieldsExtension.from(message); res.add(iotFieldsExtension);