use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class NodeSubscription method sendAuthorizationRequest.
/**
* Sends an request to authorize the pending subscription to all owners. The first
* answer sent by a owner will be processed. Rest of the answers will be discarded.
*/
public void sendAuthorizationRequest() {
Message authRequest = new Message();
authRequest.addExtension(node.getAuthRequestForm(this));
// Send authentication request to node owners
node.getService().broadcast(node, authRequest, node.getOwners());
}
use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class NodeSubscription method sendAuthorizationRequest.
/**
* Sends an request to authorize the pending subscription to the specified owner.
*
* @param owner the JID of the user that will get the authorization request.
*/
public void sendAuthorizationRequest(JID owner) {
Message authRequest = new Message();
authRequest.addExtension(node.getAuthRequestForm(this));
authRequest.setTo(owner);
authRequest.setFrom(node.getService().getAddress());
// Send authentication request to node owners
node.getService().send(authRequest);
}
use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class NodeSubscription method sendLastPublishedItem.
/**
* Sends an event notification for the last published item to the subscriber. If
* the subscription has not yet been authorized or is pending to be configured then
* no notification is going to be sent.<p>
*
* Depending on the subscription configuration the event notification may or may not have
* a payload, may not be sent if a keyword (i.e. filter) was defined and it was not matched.
*
* @param publishedItem the last item that was published to the node.
*/
void sendLastPublishedItem(PublishedItem publishedItem) {
// Check if the published item can be sent to the subscriber
if (!canSendPublicationEvent(publishedItem.getNode(), publishedItem)) {
return;
}
// Send event notification to the subscriber
Message notification = new Message();
Element event = notification.getElement().addElement("event", "http://jabber.org/protocol/pubsub#event");
Element items = event.addElement("items");
items.addAttribute("node", node.getNodeID());
Element item = items.addElement("item");
if (((LeafNode) node).isItemRequired()) {
item.addAttribute("id", publishedItem.getID());
}
if (node.isPayloadDelivered() && publishedItem.getPayload() != null) {
item.add(publishedItem.getPayload().createCopy());
}
// Add a message body (if required)
if (isIncludingBody()) {
notification.setBody(LocaleUtils.getLocalizedString("pubsub.notification.message.body"));
}
// Include date when published item was created
notification.getElement().addElement("delay", "urn:xmpp:delay").addAttribute("stamp", XMPPDateTimeFormat.format(publishedItem.getCreationDate()));
// Send the event notification to the subscriber
node.getService().sendNotification(node, notification, jid);
}
use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class CollectionNode method childNodeAdded.
/**
* Notification that a new node was created and added to this node. Trigger notifications
* to node subscribers whose subscription type is {@link NodeSubscription.Type#nodes} and
* have the proper depth.
*
* @param child the newly created node that was added to this node.
*/
void childNodeAdded(Node child) {
// Build packet to broadcast to subscribers
Message message = new Message();
Element event = message.addChildElement("event", "http://jabber.org/protocol/pubsub#event");
Element item = event.addElement("items").addElement("item");
item.addAttribute("id", child.getNodeID());
if (deliverPayloads) {
item.add(child.getMetadataForm().getElement());
}
// Broadcast event notification to subscribers
broadcastCollectionNodeEvent(child, message);
}
use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class BroadcastMessage method readExternal.
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
Element packetElement = (Element) ExternalizableUtil.getInstance().readSerializable(in);
packet = new Message(packetElement, true);
}
Aggregations