当前位置: 首页>>代码示例>>Java>>正文


Java Stanza.getExtension方法代码示例

本文整理汇总了Java中org.jivesoftware.smack.packet.Stanza.getExtension方法的典型用法代码示例。如果您正苦于以下问题:Java Stanza.getExtension方法的具体用法?Java Stanza.getExtension怎么用?Java Stanza.getExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.smack.packet.Stanza的用法示例。


在下文中一共展示了Stanza.getExtension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: accept

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
public boolean accept(Stanza packet) {
    // sender equals remote peer
    if (!packet.getFrom().equalsIgnoreCase(remoteJID)) {
        return false;
    }

    DataPacketExtension data;
    if (packet instanceof Data) {
        data = ((Data) packet).getDataPacketExtension();
    } else {
        // stanza contains data packet extension
        data = packet.getExtension(
                DataPacketExtension.ELEMENT,
                DataPacketExtension.NAMESPACE);
        if (data == null) {
            return false;
        }
    }

    // session ID equals this session ID
    if (!data.getSessionID().equals(byteStreamRequest.getSessionID())) {
        return false;
    }

    return true;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:InBandBytestreamSession.java

示例2: getSubscriptionIds

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
private static List<String> getSubscriptionIds(Stanza packet)
{
	HeadersExtension headers = (HeadersExtension)packet.getExtension("headers", "http://jabber.org/protocol/shim");
	List<String> values = null;
	
	if (headers != null)
	{
		values = new ArrayList<String>(headers.getHeaders().size());
		
		for (Header header : headers.getHeaders())
		{
			values.add(header.getValue());
		}
	}
	return values;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:17,代码来源:Node.java

示例3: processPacket

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
public void processPacket(Stanza packet)
{
       EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
       
       List<ExtensionElement> extList = event.getExtensions();
       
       if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName()))
       {
       	listener.handlePurge();
       }
       else
       {
		ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
		@SuppressWarnings("unchecked")
              Collection<RetractItem> pubItems = (Collection<RetractItem>) itemsElem.getItems();
		List<String> items = new ArrayList<String>(pubItems.size());

		for (RetractItem item : pubItems)
		{
			items.add(item.getId());
		}

		ItemDeleteEvent eventItems = new ItemDeleteEvent(itemsElem.getNode(), items, getSubscriptionIds(packet));
		listener.handleDeletedItems(eventItems);
       }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:Node.java

示例4: processStanza

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
/**
 * Handle incoming messages
 */
@SuppressWarnings("unchecked")
@Override
public void processStanza(Stanza packet) {
	logger.log(Level.INFO, "Received: " + packet.toXML());
	final FcmPacketExtension fcmPacket = (FcmPacketExtension) packet.getExtension(Util.FCM_NAMESPACE);
	final String json = fcmPacket.getJson();
	try {
		final Map<String, Object> jsonMap = (Map<String, Object>) JSONValue.parseWithException(json);
		final Object messageType = jsonMap.get("message_type");

		if (messageType == null) { // normal upstream message
			final CcsInMessage inMessage = MessageHelper.createCcsInMessage(jsonMap);
			handleUpstreamMessage(inMessage);
			return;
		}

		switch (messageType.toString()) {
		case "ack":
			handleAckReceipt(jsonMap);
			break;
		case "nack":
			handleNackReceipt(jsonMap);
			break;
		case "receipt":
			handleDeliveryReceipt(jsonMap);
			break;
		case "control":
			handleControlMessage(jsonMap);
			break;
		default:
			logger.log(Level.INFO, "Received unknown FCM message type: " + messageType.toString());
		}
	} catch (ParseException e) {
		logger.log(Level.INFO, "Error parsing JSON: " + json, e.getMessage());
	}

}
 
开发者ID:carlosCharz,项目名称:fcmxmppserverv2,代码行数:41,代码来源:CcsClient.java

示例5: getPropertiesNames

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
/**
 * Return a collection of the names of all properties of the given packet. If the packet
 * contains no properties extension, then an empty collection will be returned.
 * 
 * @param packet
 * @return a collection of the names of all properties.
 */
public static Collection<String> getPropertiesNames(Stanza packet) {
    JivePropertiesExtension jpe = (JivePropertiesExtension) packet.getExtension(JivePropertiesExtension.NAMESPACE);
    if (jpe == null) {
        return Collections.emptyList();
    }
    return jpe.getPropertyNames();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:JivePropertiesManager.java

示例6: accept

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
public boolean accept(Stanza packet)
{
	if (!(packet instanceof Message))
		return false;

	EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
	
	if (event == null)
		return false;

	NodeExtension embedEvent = event.getEvent();
	
	if (embedEvent == null)
		return false;
	
	if (embedEvent.getElementName().equals(firstElement))
	{
		if (!embedEvent.getNode().equals(getId()))
			return false;
		
		if (secondElement == null)
			return true;
		
		if (embedEvent instanceof EmbeddedPacketExtension)
		{
			List<ExtensionElement> secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions();
			
			if (secondLevelList.size() > 0 && secondLevelList.get(0).getElementName().equals(secondElement))
				return true;
		}
	}
	return false;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:34,代码来源:Node.java

示例7: getProperty

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
/**
 * Convenience method to get a property from a packet. Will return null if the stanza(/packet) contains
 * not property with the given name.
 * 
 * @param packet
 * @param name
 * @return the property or <tt>null</tt> if none found.
 */
public static Object getProperty(Stanza packet, String name) {
    Object res = null;
    JivePropertiesExtension jpe = (JivePropertiesExtension) packet.getExtension(JivePropertiesExtension.NAMESPACE);
    if (jpe != null) {
        res = jpe.getProperty(name);
    }
    return res;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:17,代码来源:JivePropertiesManager.java

示例8: parseEmptyTag

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
@Test
public void parseEmptyTag() throws Exception
{
    String itemContent = "<foo xmlns='smack:test'><bar/></foo>";
    
    XmlPullParser parser = PacketParserUtils.getParserFor(
        "<message from='pubsub.myserver.com' to='[email protected]' id='foo'>" +
            "<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
                "<items node='testNode'>" +
                    "<item id='testid1' >" +
                        itemContent +
                    "</item>" + 
                "</items>" + 
             "</event>" + 
        "</message>");
    
    Stanza message = PacketParserUtils.parseMessage(parser);
    ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
    
    assertTrue(eventExt instanceof EventElement);
    EventElement event = (EventElement) eventExt;
    assertEquals(EventElementType.items, event.getEventType());
    assertEquals(1, event.getExtensions().size());
    assertTrue(event.getExtensions().get(0) instanceof ItemsExtension);
    assertEquals(1, ((ItemsExtension)event.getExtensions().get(0)).items.size());
    
    ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0);
    assertTrue(itemExt instanceof PayloadItem<?>);
    PayloadItem<?> item = (PayloadItem<?>)itemExt;
    
    assertEquals("testid1", item.getId());
    assertTrue(item.getPayload() instanceof SimplePayload);
    
    assertXMLEqual(itemContent, ((SimplePayload)item.getPayload()).toXML().toString());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:36,代码来源:ItemValidationTest.java

示例9: parseComplexItem

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
@Test
public void parseComplexItem() throws Exception
{
    String itemContent = 
            "<entry xmlns='http://www.w3.org/2005/Atom'>" +
                "<title>Soliloquy</title>" +
                "<summary>" +
                    "To be, or not to be: that is the question:" +
                    "Whether 'tis nobler in the mind to suffer" +
                    "The slings and arrows of outrageous fortune," +
                    "Or to take arms against a sea of troubles," +
                    "And by opposing end them?" +
                "</summary>" +
                "<link rel='alternate' type='text/html' href='http://denmark.lit/2003/12/13/atom03'/>" +
                "<id>tag:denmark.lit,2003:entry-32397</id>" +
                "<published>2003-12-13T18:30:02Z</published>" +
                "<updated>2003-12-13T18:30:02Z</updated>" +
            "</entry>";
    
    XmlPullParser parser = PacketParserUtils.getParserFor(
        "<message from='pubsub.myserver.com' to='[email protected]' id='foo'>" +
            "<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
                "<items node='testNode'>" +
                    "<item id='testid1' >" +
                        itemContent +
                    "</item>" + 
                "</items>" + 
             "</event>" + 
        "</message>");
    
    Stanza message = PacketParserUtils.parseMessage(parser);
    ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
    EventElement event = (EventElement) eventExt;
    ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0);

    assertTrue(itemExt instanceof PayloadItem<?>);
    PayloadItem<?> item = (PayloadItem<?>)itemExt;
    
    assertEquals("testid1", item.getId());
    assertTrue(item.getPayload() instanceof SimplePayload);
    
    SimplePayload payload = (SimplePayload) item.getPayload();
    assertEquals("entry", payload.getElementName());
    assertEquals("http://www.w3.org/2005/Atom", payload.getNamespace());
    assertXMLEqual(itemContent, payload.toXML().toString());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:47,代码来源:ItemValidationTest.java

示例10: from

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
public static RSMSet from(Stanza packet) {
    return (RSMSet) packet.getExtension(ELEMENT, NAMESPACE);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:4,代码来源:RSMSet.java

示例11: getSubscriptions

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
/**
 * Gets the subscriptions on the root node.
 * 
 * @return List of exceptions
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException
{
	Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null);
	SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
	return subElem.getSubscriptions();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:PubSubManager.java

示例12: from

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
/**
 * Retrieve the GCM stanza(/packet) extension from the packet.
 *
 * @param packet
 * @return the GCM stanza(/packet) extension or null.
 */
public static GcmPacketExtension from(Stanza packet) {
    return packet.getExtension(ELEMENT, NAMESPACE);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:10,代码来源:GcmPacketExtension.java

示例13: from

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
/**
 * Retrieve the MUCUser PacketExtension from packet, if any.
 *
 * @param packet
 * @return the MUCUser PacketExtension or {@code null}
 */
public static MUCUser from(Stanza packet) {
    return packet.getExtension(ELEMENT, NAMESPACE);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:10,代码来源:MUCUser.java

示例14: from

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
/**
 * Retrieve the MUCInitialPresence PacketExtension from packet, if any.
 *
 * @param packet
 * @return the MUCInitialPresence PacketExtension or {@code null}
 */
public static MUCInitialPresence from(Stanza packet) {
    return packet.getExtension(ELEMENT, NAMESPACE);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:10,代码来源:MUCInitialPresence.java

示例15: from

import org.jivesoftware.smack.packet.Stanza; //导入方法依赖的package包/类
/**
 * Get the {@link DeliveryReceiptRequest} extension of the packet, if any.
 *
 * @param packet the packet
 * @return the {@link DeliveryReceiptRequest} extension or {@code null}
 */
public static DeliveryReceiptRequest from(Stanza packet) {
    return packet.getExtension(ELEMENT, DeliveryReceipt.NAMESPACE);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:10,代码来源:DeliveryReceiptRequest.java


注:本文中的org.jivesoftware.smack.packet.Stanza.getExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。