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


Java SharedGroupsInfo类代码示例

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


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

示例1: getSharedGroups

import org.jivesoftware.smackx.packet.SharedGroupsInfo; //导入依赖的package包/类
/**
 * Returns the collection that will contain the name of the shared groups where the user
 * logged in with the specified session belongs.
 *
 * @param connection connection to use to get the user's shared groups.
 * @return collection with the shared groups' name of the logged user.
 */
public static List getSharedGroups(Connection connection) throws XMPPException {
    // Discover the shared groups of the logged user
    SharedGroupsInfo info = new SharedGroupsInfo();
    info.setType(IQ.Type.GET);

    // Create a packet collector to listen for a response.
    PacketCollector collector =
        connection.createPacketCollector(new PacketIDFilter(info.getPacketID()));

    connection.sendPacket(info);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    return ((SharedGroupsInfo) result).getGroups();
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:31,代码来源:SharedGroupManager.java

示例2: getSharedGroups

import org.jivesoftware.smackx.packet.SharedGroupsInfo; //导入依赖的package包/类
/**
 * Returns the collection that will contain the name of the shared groups where the user
 * logged in with the specified session belongs.
 *
 * @param connection connection to use to get the user's shared groups.
 * @return collection with the shared groups' name of the logged user.
 */
public static List<String> getSharedGroups(Connection connection) throws XMPPException {
    // Discover the shared groups of the logged user
    SharedGroupsInfo info = new SharedGroupsInfo();
    info.setType(IQ.Type.GET);

    // Create a packet collector to listen for a response.
    PacketCollector collector =
        connection.createPacketCollector(new PacketIDFilter(info.getPacketID()));

    connection.sendPacket(info);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    return ((SharedGroupsInfo) result).getGroups();
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:31,代码来源:SharedGroupManager.java

示例3: getSharedGroups

import org.jivesoftware.smackx.packet.SharedGroupsInfo; //导入依赖的package包/类
/**
 * Returns the collection that will contain the name of the shared groups
 * where the user logged in with the specified session belongs.
 * 
 * @param connection
 *            connection to use to get the user's shared groups.
 * @return collection with the shared groups' name of the logged user.
 */
public static List getSharedGroups(Connection connection)
		throws XMPPException {
	// Discover the shared groups of the logged user
	SharedGroupsInfo info = new SharedGroupsInfo();
	info.setType(IQ.Type.GET);

	// Create a packet collector to listen for a response.
	PacketCollector collector = connection
			.createPacketCollector(new PacketIDFilter(info.getPacketID()));

	connection.sendPacket(info);

	// Wait up to 5 seconds for a result.
	IQ result = (IQ) collector.nextResult(SmackConfiguration
			.getPacketReplyTimeout());
	// Stop queuing results
	collector.cancel();
	if (result == null) {
		throw new XMPPException("No response from the server.");
	}
	if (result.getType() == IQ.Type.ERROR) {
		throw new XMPPException(result.getError());
	}
	return ((SharedGroupsInfo) result).getGroups();
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:34,代码来源:SharedGroupManager.java


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