Java 类org.jivesoftware.smack.SmackException.NotLoggedInException 实例源码

项目:Smack    文件:Roster.java   
/**
 * Reloads the entire roster from the server. This is an asynchronous operation,
 * which means the method will return immediately, and the roster will be
 * reloaded at a later point when the server responds to the reload request.
 * @throws NotLoggedInException If not logged in.
 * @throws NotConnectedException 
 */
public void reload() throws NotLoggedInException, NotConnectedException{
    final XMPPConnection connection = connection();
    if (!connection.isAuthenticated()) {
        throw new NotLoggedInException();
    }
    if (connection.isAnonymous()) {
        throw new IllegalStateException("Anonymous users can't have a roster.");
    }

    RosterPacket packet = new RosterPacket();
    if (rosterStore != null && isRosterVersioningSupported()) {
        packet.setVersion(rosterStore.getRosterVersion());
    }
    rosterState = RosterState.loading;
    connection.sendIqWithResponseCallback(packet, new RosterResultListener(), new ExceptionCallback() {
        @Override
        public void processException(Exception exception) {
            rosterState = RosterState.uninitialized;
            LOGGER.log(Level.SEVERE, "Exception reloading roster" , exception);
        }
    });
}
项目:Smack    文件:Roster.java   
/**
 * Removes a roster entry from the roster. The roster entry will also be removed from the
 * unfiled entries or from any roster group where it could belong and will no longer be part
 * of the roster. Note that this is a synchronous call -- Smack must wait for the server
 * to send an updated subscription status.
 *
 * @param entry a roster entry.
 * @throws XMPPErrorException if an XMPP error occurs.
 * @throws NotLoggedInException if not logged in.
 * @throws NoResponseException SmackException if there was no response from the server.
 * @throws NotConnectedException 
 * @throws IllegalStateException if connection is not logged in or logged in anonymously
 */
public void removeEntry(RosterEntry entry) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException {
    final XMPPConnection connection = connection();
    if (!connection.isAuthenticated()) {
        throw new NotLoggedInException();
    }
    if (connection.isAnonymous()) {
        throw new IllegalStateException("Anonymous users can't have a roster.");
    }

    // Only remove the entry if it's in the entry list.
    // The actual removal logic takes place in RosterPacketListenerprocess>>Packet(Packet)
    if (!entries.containsKey(entry.getUser())) {
        return;
    }
    RosterPacket packet = new RosterPacket();
    packet.setType(IQ.Type.set);
    RosterPacket.Item item = RosterEntry.toRosterItem(entry);
    // Set the item type as REMOVE so that the server will delete the entry
    item.setItemType(RosterPacket.ItemType.remove);
    packet.addRosterItem(item);
    connection.createPacketCollectorAndSend(packet).nextResultOrThrow();
}
项目:maxs    文件:XMPPService.java   
public void notifyAboutNewMasterAddress(final EntityBareJid newMasterAddress) {
    final XMPPConnection connection = getConnection();
    if (connection == null || !connection.isAuthenticated()) {
        return;
    }

    final Roster roster = Roster.getInstanceFor(connection);

    Async.go(new ThrowingRunnable() {
        @Override
        public void runOrThrow() throws NotLoggedInException, NotConnectedException,
                FeatureNotSupportedException, InterruptedException {
            if (roster.isSubscriptionPreApprovalSupported()) {
                roster.preApprove(newMasterAddress);
            }
            RosterUtil.askForSubscriptionIfRequired(roster, newMasterAddress);
        }
    });
}
项目:Smack    文件:Roster.java   
/**
 * Set the roster store, may cause a roster reload
 *
 * @param rosterStore
 * @return true if the roster reload was initiated, false otherwise.
 * @since 4.1
 */
public boolean setRosterStore(RosterStore rosterStore) {
    this.rosterStore = rosterStore;
    try {
        reload();
    }
    catch (NotLoggedInException | NotConnectedException e) {
        LOGGER.log(Level.FINER, "Could not reload roster", e);
        return false;
    }
    return true;
}
项目:League-of-Legends-XMPP-Chat-Library    文件:Friend.java   
/**
 * Deletes this friend.
 * 
 * @return true if succesful, otherwise false
 */
public boolean delete() {
    try {
        con.getRoster().removeEntry(get());
        return true;
    } catch (XMPPException | NotLoggedInException | NoResponseException
            | NotConnectedException e) {
        e.printStackTrace();
    }
    return false;
}
项目:Smack    文件:Roster.java   
/**
 * Reload the roster and block until it is reloaded.
 *
 * @throws NotLoggedInException
 * @throws NotConnectedException
 * @throws InterruptedException 
 * @since 4.1
 */
public void reloadAndWait() throws NotLoggedInException, NotConnectedException, InterruptedException {
    reload();
    waitUntilLoaded();
}