本文整理汇总了Java中org.jivesoftware.smackx.pubsub.packet.PubSub.addExtension方法的典型用法代码示例。如果您正苦于以下问题:Java PubSub.addExtension方法的具体用法?Java PubSub.addExtension怎么用?Java PubSub.addExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.pubsub.packet.PubSub
的用法示例。
在下文中一共展示了PubSub.addExtension方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNode
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Creates a node with specified configuration.
*
* Note: This is the only way to create a collection node.
*
* @param name 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
* @throws NoResponseException
* @throws NotConnectedException
*/
public Node createNode(String name, Form config) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub request = PubSub.createPubsubPacket(to, Type.set, new NodeExtension(PubSubElementType.CREATE, name), null);
boolean isLeafNode = true;
if (config != null)
{
request.addExtension(new FormNode(FormNodeType.CONFIGURE, config));
FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
if (nodeTypeField != null)
isLeafNode = nodeTypeField.getValues().get(0).equals(NodeType.leaf.toString());
}
// Errors will cause exceptions in getReply, so it only returns
// on success.
sendPubsubPacket(con, request);
Node newNode = isLeafNode ? new LeafNode(con, name) : new CollectionNode(con, name);
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
示例2: getSubscriptions
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
private List<Subscription> getSubscriptions(List<ExtensionElement> additionalExtensions,
Collection<ExtensionElement> returnedExtensions, PubSubNamespace pubSubNamespace)
throws NoResponseException, XMPPErrorException, NotConnectedException {
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS, getId()), pubSubNamespace);
if (additionalExtensions != null) {
for (ExtensionElement pe : additionalExtensions) {
pubSub.addExtension(pe);
}
}
PubSub reply = sendPubsubPacket(pubSub);
if (returnedExtensions != null) {
returnedExtensions.addAll(reply.getExtensions());
}
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtension(PubSubElementType.SUBSCRIPTIONS);
return subElem.getSubscriptions();
}
示例3: getAffiliations
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Get the affiliations of this node.
* <p>
* {@code additionalExtensions} can be used e.g. to add a "Result Set Management" extension.
* {@code returnedExtensions} will be filled with the stanza(/packet) extensions found in the answer.
* </p>
*
* @param additionalExtensions additional {@code PacketExtensions} add to the request
* @param returnedExtensions a collection that will be filled with the returned packet
* extensions
* @return List of {@link Affiliation}
* @throws NoResponseException
* @throws XMPPErrorException
* @throws NotConnectedException
*/
public List<Affiliation> getAffiliations(List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions)
throws NoResponseException, XMPPErrorException, NotConnectedException {
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS, getId()));
if (additionalExtensions != null) {
for (ExtensionElement pe : additionalExtensions) {
pubSub.addExtension(pe);
}
}
PubSub reply = sendPubsubPacket(pubSub);
if (returnedExtensions != null) {
returnedExtensions.addAll(reply.getExtensions());
}
AffiliationsExtension affilElem = (AffiliationsExtension) reply.getExtension(PubSubElementType.AFFILIATIONS);
return affilElem.getAffiliations();
}
示例4: createNode
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Creates a node with specified configuration.
*
* Note: This is the only way to create a collection node.
*
* @param name 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
* @exception XMPPException
*/
public Node createNode(String name, Form config)
throws XMPPException
{
PubSub request = createPubsubPacket(to, Type.SET, new NodeExtension(PubSubElementType.CREATE, name));
boolean isLeafNode = true;
if (config != null)
{
request.addExtension(new FormNode(FormNodeType.CONFIGURE, config));
FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
if (nodeTypeField != null)
isLeafNode = nodeTypeField.getValues().next().equals(NodeType.leaf.toString());
}
// Errors will cause exceptions in getReply, so it only returns
// on success.
sendPubsubPacket(con, to, Type.SET, request);
Node newNode = isLeafNode ? new LeafNode(con, name) : new CollectionNode(con, name);
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
示例5: createNode
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* Creates a node with specified configuration.
*
* Note: This is the only way to create a collection node.
*
* @param name
* 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
* @exception XMPPException
*/
public Node createNode(String name, Form config) throws XMPPException {
PubSub request = createPubsubPacket(to, Type.SET, new NodeExtension(
PubSubElementType.CREATE, name));
boolean isLeafNode = true;
if (config != null) {
request.addExtension(new FormNode(FormNodeType.CONFIGURE, config));
FormField nodeTypeField = config
.getField(ConfigureNodeFields.node_type.getFieldName());
if (nodeTypeField != null)
isLeafNode = nodeTypeField.getValues().next()
.equals(NodeType.leaf.toString());
}
// Errors will cause exceptions in getReply, so it only returns
// on success.
sendPubsubPacket(con, to, Type.SET, request);
Node newNode = isLeafNode ? new LeafNode(con, name)
: new CollectionNode(con, name);
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
示例6: parseIQ
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
public IQ parseIQ(XmlPullParser parser) throws Exception {
PubSub pubsub = new PubSub();
String namespace = parser.getNamespace();
pubsub.setPubSubNamespace(PubSubNamespace.valueOfFromXmlns(namespace));
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
PacketExtension ext = PacketParserUtils.parsePacketExtension(
parser.getName(), namespace, parser);
if (ext != null) {
pubsub.addExtension(ext);
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("pubsub")) {
done = true;
}
}
}
return pubsub;
}
示例7: sendPubsubPacket
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
static PubSub sendPubsubPacket(XMPPConnection con, String to, Type type, List<ExtensionElement> extList, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub pubSub = new PubSub(to, type, ns);
for (ExtensionElement pe : extList) {
pubSub.addExtension(pe);
}
return sendPubsubPacket(con ,pubSub);
}
示例8: createPubsubPacket
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
static PubSub createPubsubPacket(String to, Type type, PacketExtension ext, PubSubNamespace ns)
{
PubSub request = new PubSub();
request.setTo(to);
request.setType(type);
if (ns != null)
{
request.setPubSubNamespace(ns);
}
request.addExtension(ext);
return request;
}
示例9: parseIQ
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
public IQ parseIQ(XmlPullParser parser) throws Exception
{
PubSub pubsub = new PubSub();
String namespace = parser.getNamespace();
pubsub.setPubSubNamespace(PubSubNamespace.valueOfFromXmlns(namespace));
boolean done = false;
while (!done)
{
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG)
{
PacketExtension ext = PacketParserUtils.parsePacketExtension(parser.getName(), namespace, parser);
if (ext != null)
{
pubsub.addExtension(ext);
}
}
else if (eventType == XmlPullParser.END_TAG)
{
if (parser.getName().equals("pubsub"))
{
done = true;
}
}
}
return pubsub;
}
示例10: createPubsubPacket
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
static PubSub createPubsubPacket(String to, Type type, PacketExtension ext,
PubSubNamespace ns) {
PubSub request = new PubSub();
request.setTo(to);
request.setType(type);
if (ns != null) {
request.setPubSubNamespace(ns);
}
request.addExtension(ext);
return request;
}
示例11: subscribe
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* The user subscribes to the node using the supplied jid and subscription
* options. The bare jid portion of this one must match the jid for the
* connection.
*
* Please note that the {@link Subscription.State} should be checked
* on return since more actions may be required by the caller.
* {@link Subscription.State#pending} - The owner must approve the subscription
* request before messages will be received.
* {@link Subscription.State#unconfigured} - If the {@link Subscription#isConfigRequired()} is true,
* the caller must configure the subscription before messages will be received. If it is false
* the caller can configure it but is not required to do so.
* @param jid The jid to subscribe as.
* @return The subscription
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public Subscription subscribe(String jid, SubscribeForm subForm) throws NoResponseException, XMPPErrorException, NotConnectedException
{
PubSub request = createPubsubPacket(Type.set, new SubscribeExtension(jid, getId()));
request.addExtension(new FormNode(FormNodeType.OPTIONS, subForm));
PubSub reply = PubSubManager.sendPubsubPacket(con, request);
return reply.getExtension(PubSubElementType.SUBSCRIPTION);
}
示例12: subscribe
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* The user subscribes to the node using the supplied jid and subscription
* options. The bare jid portion of this one must match the jid for the
* connection.
*
* Please note that the {@link Subscription.State} should be checked
* on return since more actions may be required by the caller.
* {@link Subscription.State#pending} - The owner must approve the subscription
* request before messages will be received.
* {@link Subscription.State#unconfigured} - If the {@link Subscription#isConfigRequired()} is true,
* the caller must configure the subscription before messages will be received. If it is false
* the caller can configure it but is not required to do so.
* @param jid The jid to subscribe as.
* @return The subscription
* @exception XMPPException
*/
public Subscription subscribe(String jid, SubscribeForm subForm)
throws XMPPException
{
PubSub request = createPubsubPacket(Type.SET, new SubscribeExtension(jid, getId()));
request.addExtension(new FormNode(FormNodeType.OPTIONS, subForm));
PubSub reply = (PubSub)PubSubManager.sendPubsubPacket(con, jid, Type.SET, request);
return (Subscription)reply.getExtension(PubSubElementType.SUBSCRIPTION);
}
示例13: subscribe
import org.jivesoftware.smackx.pubsub.packet.PubSub; //导入方法依赖的package包/类
/**
* The user subscribes to the node using the supplied jid and subscription
* options. The bare jid portion of this one must match the jid for the
* connection.
*
* Please note that the {@link Subscription.State} should be checked on
* return since more actions may be required by the caller.
* {@link Subscription.State#pending} - The owner must approve the
* subscription request before messages will be received.
* {@link Subscription.State#unconfigured} - If the
* {@link Subscription#isConfigRequired()} is true, the caller must
* configure the subscription before messages will be received. If it is
* false the caller can configure it but is not required to do so.
*
* @param jid
* The jid to subscribe as.
* @return The subscription
* @exception XMPPException
*/
public Subscription subscribe(String jid, SubscribeForm subForm)
throws XMPPException {
PubSub request = createPubsubPacket(Type.SET, new SubscribeExtension(
jid, getId()));
request.addExtension(new FormNode(FormNodeType.OPTIONS, subForm));
PubSub reply = (PubSub) PubSubManager.sendPubsubPacket(con, jid,
Type.SET, request);
return (Subscription) reply
.getExtension(PubSubElementType.SUBSCRIPTION);
}