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


Java PacketExtension类代码示例

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


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

示例1: processPacket

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
/**
 * This method handles incoming packets.
 *
 * @param packet
 *            The incoming packet.
 * @throws NotConnectedException
 */
@Override
public void processPacket(Packet packet) throws NotConnectedException {
    if (!(packet instanceof Message)) {
        return;
    }
    Message message = (Message) packet;
    if (message.getBody() == null) {
        return;
    }
    PacketExtension extension = packet.getExtension(AliasPacketExtension.ALIAS_ELEMENT_NAME,
            AliasPacketExtension.ALIAS_NAMESPACE);
    if (extension == null) {
        sendMessage(
                packet.getFrom(),
                packet.getTo(),
                ResourceBundleManager.instance().getText(
                        "xmpp.message.error.bot",
                        XMPPPatternUtils.extractKenmeiUser(packet.getFrom())
                        .getLanguageLocale(),
                        XMPPPatternUtils.extractClientIdFromUser(packet.getFrom()),
                        XMPPPatternUtils.getBlogSuffix()));
    } else {
        sendMessageToCommunote(message, (AliasPacketExtension) extension);
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:33,代码来源:XMPPMessagePacketListener.java

示例2: parse

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
public PacketExtension parse(XmlPullParser parser, int initialDepth) throws Exception
{
	String color = null;
	int numTires = 0;
	
	for (int i=0; i<2; i++)
	{
		while (parser.next() != XmlPullParser.START_TAG);
		
		if (parser.getName().equals("paint"))
		{
			color = parser.getAttributeValue(0);
		}
		else
		{
			numTires = Integer.parseInt(parser.getAttributeValue(0));
		}
	}
	while (parser.next() != XmlPullParser.END_TAG);
	return new CarExtension(color, numTires);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:22,代码来源:CarExtensionProvider.java

示例3: extractHeadersFromXmpp

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
public Map<String, Object> extractHeadersFromXmpp(Packet xmppPacket, Exchange exchange) {
    Map<String, Object> answer = new HashMap<String, Object>();

    PacketExtension jpe = xmppPacket.getExtension(JivePropertiesExtension.NAMESPACE);
    if (jpe != null && jpe instanceof JivePropertiesExtension) {
        extractHeadersFrom((JivePropertiesExtension)jpe, exchange, answer);
    }
    if (jpe != null && jpe instanceof DefaultPacketExtension) {
        extractHeadersFrom((DefaultPacketExtension)jpe, exchange, answer);
    }

    if (xmppPacket instanceof Message) {
        Message xmppMessage = (Message) xmppPacket;
        answer.put(XmppConstants.MESSAGE_TYPE, xmppMessage.getType());
        answer.put(XmppConstants.SUBJECT, xmppMessage.getSubject());
        answer.put(XmppConstants.THREAD_ID, xmppMessage.getThread());
    } else if (xmppPacket instanceof PubSub) {
        PubSub pubsubPacket = (PubSub) xmppPacket;
        answer.put(XmppConstants.MESSAGE_TYPE, pubsubPacket.getType());
    }
    answer.put(XmppConstants.FROM, xmppPacket.getFrom());
    answer.put(XmppConstants.PACKET_ID, xmppPacket.getPacketID());
    answer.put(XmppConstants.TO, xmppPacket.getTo());

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:XmppBinding.java

示例4: parseExtension

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
/**
 * Parses a PEPEvent packet and extracts a PEPItem from it.
 * (There is only one per <event>.)
 *
 * @param parser the XML parser, positioned at the starting element of the extension.
 * @return a PacketExtension.
 * @throws Exception if a parsing error occurs.
 */
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {

    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("event")) {
            } else if (parser.getName().equals("items")) {
                // Figure out the node for this event.
                String node = parser.getAttributeValue("", "node");
                // Get the parser for this kind of node, and if found then parse the node.
                PacketExtensionProvider nodeParser = nodeParsers.get(node);
                if (nodeParser != null) {
                    pepItem = nodeParser.parseExtension(parser);
                }
             }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("event")) {
                done = true;
            }
        }
    }

    return pepItem;
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:34,代码来源:PEPProvider.java

示例5: parseExtension

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
    boolean done = false;
    MultipleAddresses multipleAddresses = new MultipleAddresses();
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("address")) {
                String type = parser.getAttributeValue("", "type");
                String jid = parser.getAttributeValue("", "jid");
                String node = parser.getAttributeValue("", "node");
                String desc = parser.getAttributeValue("", "desc");
                boolean delivered = "true".equals(parser.getAttributeValue("", "delivered"));
                String uri = parser.getAttributeValue("", "uri");
                // Add the parsed address
                multipleAddresses.addAddress(type, jid, node, desc, delivered, uri);
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals(multipleAddresses.getElementName())) {
                done = true;
            }
        }
    }
    return multipleAddresses;
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:25,代码来源:MultipleAddressesProvider.java

示例6: parseExtension

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
/**
 * Parses a OfflineMessageInfo packet (extension sub-packet).
 *
 * @param parser the XML parser, positioned at the starting element of the extension.
 * @return a PacketExtension.
 * @throws Exception if a parsing error occurs.
 */
public PacketExtension parseExtension(XmlPullParser parser)
    throws Exception {
    OfflineMessageInfo info = new OfflineMessageInfo();
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("item"))
                info.setNode(parser.getAttributeValue("", "node"));
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("offline")) {
                done = true;
            }
        }
    }

    return info;
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:26,代码来源:OfflineMessageInfo.java

示例7: parseExtension

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
    AgentStatus agentStatus = new AgentStatus();

    agentStatus.workgroupJID = parser.getAttributeValue("", "jid");

    boolean done = false;
    while (!done) {
        int eventType = parser.next();

        if (eventType == XmlPullParser.START_TAG) {
            if ("chat".equals(parser.getName())) {
                agentStatus.currentChats.add(parseChatInfo(parser));
            }
            else if ("max-chats".equals(parser.getName())) {
                agentStatus.maxChats = Integer.parseInt(parser.nextText());
            }
        }
        else if (eventType == XmlPullParser.END_TAG &&
            ELEMENT_NAME.equals(parser.getName())) {
            done = true;
        }
    }
    return agentStatus;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:25,代码来源:AgentStatus.java

示例8: accept

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

    // stanza contains data packet extension
    PacketExtension packetExtension = packet.getExtension(DataPacketExtension.ELEMENT_NAME,
                    InBandBytestreamManager.NAMESPACE);
    if (packetExtension == null || !(packetExtension instanceof DataPacketExtension)) {
        return false;
    }

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

    return true;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:22,代码来源:InBandBytestreamSession.java

示例9: parseExtension

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
final public PacketExtension parseExtension(XmlPullParser parser) throws Exception
{
       String namespace = parser.getNamespace();
       String name = parser.getName();
       Map<String, String> attMap = new HashMap<String, String>();
       
       for(int i=0; i<parser.getAttributeCount(); i++)
       {
       	attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i));
       }
       List<PacketExtension> extensions = new ArrayList<PacketExtension>();
       
       do
       {
           int tag = parser.next();

           if (tag == XmlPullParser.START_TAG) 
           	extensions.add(PacketParserUtils.parsePacketExtension(parser.getName(), parser.getNamespace(), parser));
       } while (!name.equals(parser.getName()));

	return createReturnExtension(name, namespace, attMap, extensions);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:23,代码来源:EmbeddedExtensionProvider.java

示例10: CcsClient

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
private CcsClient() {
	// Add FcmPacketExtension
	ProviderManager.getInstance().addExtensionProvider(Util.FCM_ELEMENT_NAME, Util.FCM_NAMESPACE,
			new PacketExtensionProvider() {

				@Override
				public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
					String json = parser.nextText();
					FcmPacketExtension packet = new FcmPacketExtension(json);
					return packet;
				}
			});
}
 
开发者ID:carlosCharz,项目名称:fcmxmppserver,代码行数:14,代码来源:CcsClient.java

示例11: getFormFrom

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
/**
 * Returns a new ReportedData if the packet is used for gathering data and includes an 
 * extension that matches the elementName and namespace "x","jabber:x:data".  
 * 
 * @param packet the packet used for gathering data.
 * @return the data form parsed from the packet or <tt>null</tt> if there was not
 *      a form in the packet.
 */
public static Form getFormFrom(Packet packet) {
    // Check if the packet includes the DataForm extension
    PacketExtension packetExtension = packet.getExtension("x","jabber:x:data");
    if (packetExtension != null) {
        // Check if the existing DataForm is not a result of a search
        DataForm dataForm = (DataForm) packetExtension;
        if (dataForm.getReportedData() == null)
            return new Form(dataForm);
    }
    // Otherwise return null
    return null;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:21,代码来源:Form.java

示例12: parseExtension

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
/**
 * PacketExtensionProvider implementation
 */
public PacketExtension parseExtension (XmlPullParser parser)
    throws Exception {
    String workgroupJID = parser.getAttributeValue("", "jid");

    // since this is a start and end tag, and we arrive on the start, this should guarantee
    //      we leave on the end
    parser.next();

    return new WorkgroupInformation(workgroupJID);
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:14,代码来源:WorkgroupInformation.java

示例13: createPubsubPacket

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的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;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:15,代码来源:PubSubManager.java

示例14: parseExtension

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
    ChatState state;
    try {
        state = ChatState.valueOf(parser.getName());
    }
    catch (Exception ex) {
        state = ChatState.active;
    }
    return new ChatStateExtension(state);
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:11,代码来源:ChatStateExtension.java

示例15: parseExtension

import org.jivesoftware.smack.packet.PacketExtension; //导入依赖的package包/类
public PacketExtension parseExtension(XmlPullParser parser)
		throws Exception {
	
          parser.next();
	final String name = parser.getText();

	// Advance to end of extension.
	while(parser.getEventType() != XmlPullParser.END_TAG) {
		parser.next();
	}

	return new Nick(name);
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:14,代码来源:Nick.java


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