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


Java Connection.getServiceName方法代码示例

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


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

示例1: getMultipleRecipienServiceAddress

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
/**
 * Returns the address of the multiple recipients service. To obtain such address service
 * discovery is going to be used on the connected server and if none was found then another
 * attempt will be tried on the server items. The discovered information is going to be
 * cached for 24 hours.
 *
 * @param connection the connection to use for disco. The connected server is going to be
 *                   queried.
 * @return the address of the multiple recipients service or <tt>null</tt> if none was found.
 */
private static String getMultipleRecipienServiceAddress(Connection connection) {
    String serviceName = connection.getServiceName();
    String serviceAddress = (String) services.get(serviceName);
    if (serviceAddress == null) {
        synchronized (services) {
            serviceAddress = (String) services.get(serviceName);
            if (serviceAddress == null) {

                // Send the disco packet to the server itself
                try {
                    DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection)
                            .discoverInfo(serviceName);
                    // Check if the server supports JEP-33
                    if (info.containsFeature("http://jabber.org/protocol/address")) {
                        serviceAddress = serviceName;
                    }
                    else {
                        // Get the disco items and send the disco packet to each server item
                        DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection)
                                .discoverItems(serviceName);
                        for (Iterator it = items.getItems(); it.hasNext();) {
                            DiscoverItems.Item item = (DiscoverItems.Item) it.next();
                            info = ServiceDiscoveryManager.getInstanceFor(connection)
                                    .discoverInfo(item.getEntityID(), item.getNode());
                            if (info.containsFeature("http://jabber.org/protocol/address")) {
                                serviceAddress = serviceName;
                                break;
                            }
                        }

                    }
                    // Cache the discovered information
                    services.put(serviceName, serviceAddress == null ? "" : serviceAddress);
                }
                catch (XMPPException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    return "".equals(serviceAddress) ? null : serviceAddress;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:54,代码来源:MultipleRecipientManager.java

示例2: getMultipleRecipienServiceAddress

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
/**
 * Returns the address of the multiple recipients service. To obtain such address service
 * discovery is going to be used on the connected server and if none was found then another
 * attempt will be tried on the server items. The discovered information is going to be
 * cached for 24 hours.
 *
 * @param connection the connection to use for disco. The connected server is going to be
 *                   queried.
 * @return the address of the multiple recipients service or <tt>null</tt> if none was found.
 */
private static String getMultipleRecipienServiceAddress(Connection connection) {
    String serviceName = connection.getServiceName();
    String serviceAddress = (String) services.get(serviceName);
    if (serviceAddress == null) {
        synchronized (services) {
            serviceAddress = (String) services.get(serviceName);
            if (serviceAddress == null) {

                // Send the disco packet to the server itself
                try {
                    DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection)
                            .discoverInfo(serviceName);
                    // Check if the server supports JEP-33
                    if (info.containsFeature("http://jabber.org/protocol/address")) {
                        serviceAddress = serviceName;
                    }
                    else {
                        // Get the disco items and send the disco packet to each server item
                        DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection)
                                .discoverItems(serviceName);
                        for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
                            DiscoverItems.Item item = it.next();
                            info = ServiceDiscoveryManager.getInstanceFor(connection)
                                    .discoverInfo(item.getEntityID(), item.getNode());
                            if (info.containsFeature("http://jabber.org/protocol/address")) {
                                serviceAddress = serviceName;
                                break;
                            }
                        }

                    }
                    // Cache the discovered information
                    services.put(serviceName, serviceAddress == null ? "" : serviceAddress);
                }
                catch (XMPPException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    return "".equals(serviceAddress) ? null : serviceAddress;
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:54,代码来源:MultipleRecipientManager.java

示例3: PubSubManager

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
/**
 * Create a pubsub manager associated to the specified connection.  Defaults the service
 * name to <i>pubsub</i>
 * 
 * @param connection The XMPP connection
 */
public PubSubManager(Connection connection)
{
	con = connection;
	to = "pubsub." + connection.getServiceName();
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:12,代码来源:PubSubManager.java


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