protected Stanza(Stanza p) { id = p.getStanzaId(); to = p.getTo(); from = p.getFrom(); error = p.error; // Copy extensions for (ExtensionElement pe : p.getExtensions()) { addExtension(pe); } }
/** * Get data form from stanza. * @param packet * @return the DataForm or null */ public static DataForm from(Stanza packet) { return (DataForm) packet.getExtension(ELEMENT, NAMESPACE); }
private static void sendToIndividualRecipients(XMPPConnection connection, Stanza packet, Collection<? extends Jid> to, Collection<? extends Jid> cc, Collection<? extends Jid> bcc) throws NotConnectedException, InterruptedException { if (to != null) { for (Jid jid : to) { packet.setTo(jid); connection.sendStanza(new PacketCopy(packet.toXML(null))); } } if (cc != null) { for (Jid jid : cc) { packet.setTo(jid); connection.sendStanza(new PacketCopy(packet.toXML(null))); } } if (bcc != null) { for (Jid jid : bcc) { packet.setTo(jid); connection.sendStanza(new PacketCopy(packet.toXML(null))); } } }
/** * Set the stanza id if none is set. * * @return the stanza id. * @since 4.2 */ public String setStanzaId() { if (!hasStanzaIdSet()) { setStanzaId(StanzaIdUtil.newStanzaId()); } return getStanzaId(); }
protected void logCommonAttributes(StringBuilder sb) { if (getTo() != null) { sb.append("to=").append(to).append(','); } if (getFrom() != null) { sb.append("from=").append(from).append(','); } if (hasStanzaIdSet()) { sb.append("id=").append(id).append(','); } }
@Override protected Jid getJidToInspect(Stanza stanza) { return stanza.getFrom(); }
/** * Add to, from, id and 'xml:lang' attributes * * @param xml the {@link XmlStringBuilder}. * @param enclosingNamespace the enclosing XML namespace. * @return the set namespace for this stanza. */ protected String addCommonAttributes(XmlStringBuilder xml, String enclosingNamespace) { String namespace; if (enclosingNamespace == null || !enclosingNamespace.equals(StreamOpen.CLIENT_NAMESPACE) || !enclosingNamespace.equals(StreamOpen.SERVER_NAMESPACE)) { namespace = StreamOpen.CLIENT_NAMESPACE; } else { namespace = enclosingNamespace; } xml.xmlnsAttribute(namespace); xml.optAttribute("to", getTo()); xml.optAttribute("from", getFrom()); xml.optAttribute("id", getStanzaId()); xml.xmllangAttribute(getLanguage()); return namespace; }
@Override protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) { buf.append(" sessionID=\"") .append(sessionID) .append("\">"); for (Stanza packet : packets) { buf.append(packet.toXML(null)); } return buf; } }
public static Version createResultFor(Stanza request, Version version) { Version result = new Version(version); result.setStanzaId(request.getStanzaId()); result.setTo(request.getFrom()); return result; } }
@Override public void processStanza(Stanza packet) throws NotConnectedException { DeliveryReceipt dr = DeliveryReceipt.from((Message) packet); // notify listeners of incoming receipt for (ReceiptReceivedListener l : receiptReceivedListeners) { l.onReceiptReceived(packet.getFrom(), packet.getTo(), dr.getId(), packet); } } }, MESSAGES_WITH_DELIVERY_RECEIPT);
Stanza targetResponse = protocol.getRequests().remove(0); assertTrue(IQ.class.isInstance(targetResponse)); assertEquals(initiatorJID, targetResponse.getTo()); assertEquals(IQ.Type.error, ((IQ) targetResponse).getType()); assertEquals(StanzaError.Condition.item_not_found, targetResponse.getError().getCondition());
/** * Convenience method to add a property to a packet. * * @param packet the stanza to add the property to. * @param name the name of the property to add. * @param value the value of the property to add. */ public static void addProperty(Stanza packet, String name, Object value) { JivePropertiesExtension jpe = (JivePropertiesExtension) packet.getExtension(JivePropertiesExtension.NAMESPACE); if (jpe == null) { jpe = new JivePropertiesExtension(); packet.addExtension(jpe); } jpe.setProperty(name, value); }
presencePacketWithSSRC.setTo(recipient); presencePacketWithSSRC.addExtension(new Nick(this.nickname)); MediaPacketExtension mediaPacket = new MediaPacketExtension(); for(String key : contentMap.keySet()) MediaDirection.SENDRECV.toString()); presencePacketWithSSRC.addExtension(mediaPacket); System.out.println("Sending presence packet with ssrc: " + presencePacketWithSSRC.toXML()); connection.sendStanza(presencePacketWithSSRC);
packet.setTo(serviceAddress); packet.addExtension(multipleAddresses);
/** * Creates a new stanza ID filter using the specified stanza's ID. * * @param stanza the stanza which the ID is taken from. */ public StanzaIdFilter(Stanza stanza) { this(stanza.getStanzaId()); }
logger.info("Processing packet in thread {} - {}", Thread.currentThread().getName(), Thread.currentThread().getId()); logger.info("Received: {}", packet.toXML(null)); final FcmPacketExtension fcmPacket = (FcmPacketExtension) packet.getExtension(Util.FCM_NAMESPACE); final String json = fcmPacket.getJson(); Optional<Map<String, Object>> jsonMapObject = Optional.ofNullable(MessageMapper.toMapFromJsonString(json));
/** * Adds a collection of stanza extensions to the packet. Does nothing if extensions is null. * * @param extensions a collection of stanza extensions */ public void addExtensions(Collection<ExtensionElement> extensions) { if (extensions == null) return; for (ExtensionElement packetExtension : extensions) { addExtension(packetExtension); } }
@Override protected Jid getAddressToCompare(Stanza stanza) { return stanza.getTo(); }
/** * Add the given extension and override eventually existing extensions with the same name and * namespace. * * @param extension the extension element to add. * @return one of the removed extensions or <code>null</code> if there are none. * @since 4.1.2 */ public ExtensionElement overrideExtension(ExtensionElement extension) { if (extension == null) return null; synchronized (packetExtensions) { // Note that we need to use removeExtension(String, String) here. If would use // removeExtension(ExtensionElement) then we would remove based on the equality of ExtensionElement, which // is not what we want in this case. ExtensionElement removedExtension = removeExtension(extension.getElementName(), extension.getNamespace()); addExtension(extension); return removedExtension; } }
+ " Maybe the response timed out."; else if (response.getError() != null) XMPPError error = response.getError(); if (XMPPError.Condition .bad_request.equals(error.getCondition())) allocChannelsErrorMsg = "Failed to allocate colibri channels - bad request: " + response.toXML(); allocChannelsErrorMsg = "Failed to allocate colibri channels: " + response.toXML(); response == null ? null : new Exception(response.toXML().toString()));