Java Code Examples for org.jivesoftware.smackx.pubsub.packet.PubSub#createPubsubPacket()
The following examples show how to use
org.jivesoftware.smackx.pubsub.packet.PubSub#createPubsubPacket() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlogPostDetailsActivity.java From mangosta-android with Apache License 2.0 | 6 votes |
public BlogPostComment sendBlogPostComment(String content, BlogPost blogPost) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException { Jid jid = XMPPSession.getInstance().getUser().asEntityBareJid(); String userName = XMPPUtils.fromJIDToUserName(jid.toString()); Jid pubSubServiceJid = XMPPSession.getInstance().getPubSubService(); // create stanza PublishCommentExtension publishCommentExtension = new PublishCommentExtension(blogPost.getId(), userName, jid, content, new Date()); PubSub publishCommentPubSub = PubSub.createPubsubPacket(pubSubServiceJid, IQ.Type.set, publishCommentExtension, null); // send stanza XMPPSession.getInstance().sendStanza(publishCommentPubSub); return new BlogPostComment(publishCommentExtension.getId(), blogPost.getId(), content, userName, jid.toString(), publishCommentExtension.getPublished()); }
Example 2
Source File: PubSubManager.java From Smack with Apache License 2.0 | 6 votes |
/** * Creates a node with specified configuration. * * Note: This is the only way to create a collection node. * * @param nodeId The name of the node, which must be unique within the * pubsub service * @param config The configuration for the node * @return The node that was created * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the remote entity. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public Node createNode(String nodeId, FillableConfigureForm config) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub request = PubSub.createPubsubPacket(pubSubService, Type.set, new NodeExtension(PubSubElementType.CREATE, nodeId)); boolean isLeafNode = true; if (config != null) { DataForm submitForm = config.getDataFormToSubmit(); request.addExtension(new FormNode(FormNodeType.CONFIGURE, submitForm)); NodeType nodeType = config.getNodeType(); // Note that some implementations do to have the pubsub#node_type field in their defauilt configuration, // which I believe to be a bug. However, since PubSub specifies the default node type to be 'leaf' we assume // leaf if the field does not exist. isLeafNode = nodeType == null || nodeType == NodeType.leaf; } // Errors will cause exceptions in getReply, so it only returns // on success. sendPubsubPacket(request); Node newNode = isLeafNode ? new LeafNode(this, nodeId) : new CollectionNode(this, nodeId); nodeMap.put(newNode.getId(), newNode); return newNode; }
Example 3
Source File: Node.java From Smack with Apache License 2.0 | 4 votes |
protected PubSub createPubsubPacket(Type type, NodeExtension ext) { return PubSub.createPubsubPacket(pubSubManager.getServiceJid(), type, ext); }