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


Java Connection.isAuthenticated方法代码示例

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


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

示例1: run

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
public void run() {
    Connection connection = weakConnection.get();
    if (connection == null) {
        // connection has been collected by GC
        // which means we can stop the thread by breaking the loop
        return;
    }
    if (connection.isAuthenticated()) {
        PingManager pingManager = PingManager.getInstanceFor(connection);
        boolean res = false;

        for (int i = 0; i < tries; i++) {
            if (i != 0) {
                try {
                    Thread.sleep(delta);
                } catch (InterruptedException e) {
                    // We received an interrupt
                    // This only happens if we should stop pinging
                    return;
                }
            }
            res = pingManager.pingMyServer();
            // stop when we receive a pong back
            if (res) {
                pingManager.lastSuccessfulPingByTask = System.currentTimeMillis();
                break;
            }
        }
        if (!res) {
            Set<PingFailedListener> pingFailedListeners = pingManager.getPingFailedListeners();
            for (PingFailedListener l : pingFailedListeners) {
                l.pingFailed();
            }
        } else {
            // Ping was successful, wind-up the periodic task again
            pingManager.maybeSchedulePingServerTask();
        }
    }
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:40,代码来源:ServerPingTask.java

示例2: checkAuthenticated

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
private void checkAuthenticated(Connection connection, boolean checkForAnonymous) {
    if (connection == null) {
        throw new IllegalArgumentException("No connection was provided");
    }
    if (!connection.isAuthenticated()) {
        throw new IllegalArgumentException("Connection is not authenticated");
    }
    if (checkForAnonymous && connection.isAnonymous()) {
        throw new IllegalArgumentException("Connection cannot be anonymous");
    }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:12,代码来源:VCard.java

示例3: updateLocalEntityCaps

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
/**
 * Updates the local user Entity Caps information with the data provided
 * 
 * If we are connected and there was already a presence send, another
 * presence is send to inform others about your new Entity Caps node string.
 * 
 * @param discoverInfo
 *            the local users discover info (mostly the service discovery
 *            features)
 * @param identityType
 *            the local users identity type
 * @param identityName
 *            the local users identity name
 * @param extendedInfo
 *            the local users extended info
 */
public void updateLocalEntityCaps() {
    Connection connection = weakRefConnection.get();

    DiscoverInfo discoverInfo = new DiscoverInfo();
    discoverInfo.setType(IQ.Type.RESULT);
    discoverInfo.setNode(getLocalNodeVer());
    if (connection != null)
        discoverInfo.setFrom(connection.getUser());
    sdm.addDiscoverInfoTo(discoverInfo);

    currentCapsVersion = generateVerificationString(discoverInfo, "sha-1");
    addDiscoverInfoByNode(ENTITY_NODE + '#' + currentCapsVersion, discoverInfo);
    if (lastLocalCapsVersions.size() > 10) {
        String oldCapsVersion = lastLocalCapsVersions.poll();
        sdm.removeNodeInformationProvider(ENTITY_NODE + '#' + oldCapsVersion);
    }
    lastLocalCapsVersions.add(currentCapsVersion);

    caps.put(currentCapsVersion, discoverInfo);
    if (connection != null)
        jidCaps.put(connection.getUser(), new NodeVerHash(ENTITY_NODE, currentCapsVersion, "sha-1"));

    final List<Identity> identities = new LinkedList<Identity>(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities());
    sdm.setNodeInformationProvider(ENTITY_NODE + '#' + currentCapsVersion, new NodeInformationProvider() {
        List<String> features = sdm.getFeaturesList();
        List<PacketExtension> packetExtensions = sdm.getExtendedInfoAsList();

        @Override
        public List<Item> getNodeItems() {
            return null;
        }

        @Override
        public List<String> getNodeFeatures() {
            return features;
        }

        @Override
        public List<Identity> getNodeIdentities() {
            return identities;
        }

        @Override
        public List<PacketExtension> getNodePacketExtensions() {
            return packetExtensions;
        }
    });

    // Send an empty presence, and let the packet intercepter
    // add a <c/> node to it.
    // See http://xmpp.org/extensions/xep-0115.html#advertise
    // We only send a presence packet if there was already one send
    // to respect ConnectionConfiguration.isSendPresence()
    if (connection != null && connection.isAuthenticated() && presenceSend) {
        Presence presence = new Presence(Presence.Type.available);
        connection.sendPacket(presence);
    }
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:75,代码来源:EntityCapsManager.java

示例4: PrivateDataManager

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
/**
 * Creates a new private data manager. The connection must have
 * undergone a successful login before being used to construct an instance of
 * this class.
 *
 * @param connection an XMPP connection which must have already undergone a
 *      successful login.
 */
public PrivateDataManager(Connection connection) {
    if (!connection.isAuthenticated()) {
        throw new IllegalStateException("Must be logged in to XMPP server.");
    }
    this.connection = connection;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:15,代码来源:PrivateDataManager.java

示例5: BookmarkManager

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
/**
 * Default constructor. Registers the data provider with the private data manager in the
 * storage:bookmarks namespace.
 *
 * @param connection the connection for persisting and retrieving bookmarks.
 * @throws XMPPException thrown when the connection is null or has not been authenticated.
 */
private BookmarkManager(Connection connection) throws XMPPException {
    if(connection == null || !connection.isAuthenticated()) {
        throw new XMPPException("Invalid connection.");
    }
    this.privateDataManager = new PrivateDataManager(connection);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:14,代码来源:BookmarkManager.java


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