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


Java NoResponseException类代码示例

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


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

示例1: authenticateAnonymously

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Performs ANONYMOUS SASL authentication. If SASL authentication was successful
 * then resource binding and session establishment will be performed. This method will return
 * the full JID provided by the server while binding a resource to the connection.<p>
 *
 * The server will assign a full JID with a randomly generated resource and possibly with
 * no username.
 *
 * @throws SASLErrorException 
 * @throws XMPPErrorException if an error occures while authenticating.
 * @throws SmackException if there was no response from the server.
 */
public void authenticateAnonymously() throws SASLErrorException,
                SmackException, XMPPErrorException {
    currentMechanism = (new SASLAnonymous()).instanceForAuthentication(connection);

    // Wait until SASL negotiation finishes
    synchronized (this) {
        currentMechanism.authenticate(null, null, null, "");
        try {
            wait(connection.getPacketReplyTimeout());
        }
        catch (InterruptedException e) {
            // Ignore
        }
    }

    maybeThrowException();

    if (!authenticationSuccessful) {
        throw NoResponseException.newWith(connection);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:34,代码来源:SASLAuthentication.java

示例2: sendAndWaitForResponse

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Send the given top level stream element and wait for a response.
 *
 * @param request the plain stream element to send.
 * @throws NoResponseException if no response was received.
 * @throws NotConnectedException if the connection is not connected.
 */
public void sendAndWaitForResponse(TopLevelStreamElement request) throws NoResponseException,
                NotConnectedException {
    assert (state == State.Initial);
    connectionLock.lock();
    try {
        if (request != null) {
            if (request instanceof Stanza) {
                connection.sendStanza((Stanza) request);
            }
            else if (request instanceof PlainStreamElement){
                connection.send((PlainStreamElement) request);
            } else {
                throw new IllegalStateException("Unsupported element type");
            }
            state = State.RequestSent;
        }
        waitForConditionOrTimeout();
    }
    finally {
        connectionLock.unlock();
    }
    checkForResponse();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:31,代码来源:SynchronizationPoint.java

示例3: setStatus

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Sets the agent's current status with the workgroup. The presence mode affects how offers
 * are routed to the agent. The possible presence modes with their meanings are as follows:<ul>
 * <p/>
 * <li>Presence.Mode.AVAILABLE -- (Default) the agent is available for more chats
 * (equivalent to Presence.Mode.CHAT).
 * <li>Presence.Mode.DO_NOT_DISTURB -- the agent is busy and should not be disturbed.
 * However, special case, or extreme urgency chats may still be offered to the agent.
 * <li>Presence.Mode.AWAY -- the agent is not available and should not
 * have a chat routed to them (equivalent to Presence.Mode.EXTENDED_AWAY).</ul>
 *
 * @param presenceMode the presence mode of the agent.
 * @param status       sets the status message of the presence update.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 * @throws IllegalStateException if the agent is not online with the workgroup.
 */
public void setStatus(Presence.Mode presenceMode, String status) throws NoResponseException, XMPPErrorException, NotConnectedException {
    if (!online) {
        throw new IllegalStateException("Cannot set status when the agent is not online.");
    }

    if (presenceMode == null) {
        presenceMode = Presence.Mode.available;
    }
    this.presenceMode = presenceMode;

    Presence presence = new Presence(Presence.Type.available);
    presence.setMode(presenceMode);
    presence.setTo(this.getWorkgroupJID());

    if (status != null) {
        presence.setStatus(status);
    }
    presence.addExtension(new MetaData(this.metaData));

    PacketCollector collector = this.connection.createPacketCollectorAndSend(new AndFilter(new StanzaTypeFilter(Presence.class),
            FromMatchesFilter.create(workgroupJID)), presence);

    collector.nextResultOrThrow();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:43,代码来源:AgentSession.java

示例4: changeSubject

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Changes the subject within the room. As a default, only users with a role of "moderator"
 * are allowed to change the subject in a room. Although some rooms may be configured to
 * allow a mere participant or even a visitor to change the subject.
 *
 * @param subject the new room's subject to set.
 * @throws XMPPErrorException if someone without appropriate privileges attempts to change the
 *          room subject will throw an error with code 403 (i.e. Forbidden)
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException 
 */
public void changeSubject(final String subject) throws NoResponseException, XMPPErrorException, NotConnectedException {
    Message message = createMessage();
    message.setSubject(subject);
    // Wait for an error or confirmation message back from the server.
    StanzaFilter responseFilter = new AndFilter(fromRoomGroupchatFilter, new StanzaFilter() {
        @Override
        public boolean accept(Stanza packet) {
            Message msg = (Message) packet;
            return subject.equals(msg.getSubject());
        }
    });
    PacketCollector response = connection.createPacketCollectorAndSend(responseFilter, message);
    // Wait up to a certain number of seconds for a reply.
    response.nextResultOrThrow();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:MultiUserChat.java

示例5: executeAction

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Executes the <code>action</code> with the <code>form</code>.
 * The action could be any of the available actions. The form must
 * be the answer of the previous stage. It can be <tt>null</tt> if it is the first stage.
 *
 * @param action the action to execute.
 * @param form the form with the information.
 * @throws XMPPErrorException if there is a problem executing the command.
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException 
 */
private void executeAction(Action action, Form form) throws NoResponseException, XMPPErrorException, NotConnectedException {
    // TODO: Check that all the required fields of the form were filled, if
    // TODO: not throw the corresponding exeption. This will make a faster response,
    // TODO: since the request is stoped before it's sent.
    AdHocCommandData data = new AdHocCommandData();
    data.setType(IQ.Type.set);
    data.setTo(getOwnerJID());
    data.setNode(getNode());
    data.setSessionID(sessionID);
    data.setAction(action);

    if (form != null) {
        data.setForm(form.getDataFormToSend());
    }

    AdHocCommandData responseData = (AdHocCommandData) connection.createPacketCollectorAndSend(
                    data).nextResultOrThrow();

    this.sessionID = responseData.getSessionID();
    super.setData(responseData);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:33,代码来源:RemoteCommand.java

示例6: removeBookmarkedConference

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Removes a conference from the bookmarks.
 *
 * @param jid the jid of the conference to be removed.
 * @throws XMPPErrorException thrown when there is a problem with the connection attempting to
 * retrieve the bookmarks or persist the bookmarks.
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException 
 * @throws IllegalArgumentException thrown when the conference being removed is a shared
 * conference
 */
public void removeBookmarkedConference(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
    retrieveBookmarks();
    Iterator<BookmarkedConference> it = bookmarks.getBookmarkedConferences().iterator();
    while(it.hasNext()) {
        BookmarkedConference conference = it.next();
        if(conference.getJid().equalsIgnoreCase(jid)) {
            if(conference.isShared()) {
                throw new IllegalArgumentException("Conference is shared and can't be removed");
            }
            it.remove();
            privateDataManager.setPrivateData(bookmarks);
            return;
        }
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:BookmarkManager.java

示例7: createNode

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Creates a node with specified configuration.
 * 
 * Note: This is the only way to create a collection node.
 * 
 * @param name The name of the node, which must be unique within the 
 * pubsub service
 * @param config The configuration for the node
 * @return The node that was created
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */
public Node createNode(String name, Form config) throws NoResponseException, XMPPErrorException, NotConnectedException
{
	PubSub request = PubSub.createPubsubPacket(to, Type.set, new NodeExtension(PubSubElementType.CREATE, name), null);
	boolean isLeafNode = true;
	
	if (config != null)
	{
		request.addExtension(new FormNode(FormNodeType.CONFIGURE, config));
		FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
		
		if (nodeTypeField != null)
			isLeafNode = nodeTypeField.getValues().get(0).equals(NodeType.leaf.toString());
	}

	// Errors will cause exceptions in getReply, so it only returns
	// on success.
	sendPubsubPacket(con, request);
	Node newNode = isLeafNode ? new LeafNode(con, name) : new CollectionNode(con, name);
	newNode.setTo(to);
	nodeMap.put(newNode.getId(), newNode);
	
	return newNode;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:37,代码来源:PubSubManager.java

示例8: createOrJoin

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Like {@link #create(String)}, but will return true if the room creation was acknowledged by
 * the service (with an 201 status code). It's up to the caller to decide, based on the return
 * value, if he needs to continue sending the room configuration. If false is returned, the room
 * already existed and the user is able to join right away, without sending a form.
 *
 * @param nickname the nickname to use.
 * @param password the password to use.
 * @param history the amount of discussion history to receive while joining a room.
 * @param timeout the amount of time to wait for a reply from the MUC service(in milliseconds).
 * @return true if the room creation was acknowledged by the service, false otherwise.
 * @throws XMPPErrorException if the room couldn't be created for some reason (e.g. 405 error if
 *         the user is not allowed to create the room)
 * @throws NoResponseException if there was no response from the server.
 */
public synchronized boolean createOrJoin(String nickname, String password, DiscussionHistory history, long timeout)
                throws NoResponseException, XMPPErrorException, SmackException {
    if (joined) {
        throw new IllegalStateException("Creation failed - User already joined the room.");
    }

    Presence presence = enter(nickname, password, history, timeout);

    // Look for confirmation of room creation from the server
    MUCUser mucUser = MUCUser.from(presence);
    if (mucUser != null && mucUser.getStatus().contains(Status.ROOM_CREATED_201)) {
        // Room was created and the user has joined the room
        return true;
    }
    return false;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:32,代码来源:MultiUserChat.java

示例9: shutdown

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Shuts down the stanza(/packet) writer. Once this method has been called, no further
 * packets will be written to the server.
 */
void shutdown(boolean instant) {
    instantShutdown = instant;
    shutdownTimestamp = System.currentTimeMillis();
    queue.shutdown();
    try {
        shutdownDone.checkIfSuccessOrWait();
    }
    catch (NoResponseException e) {
        LOGGER.log(Level.WARNING, "shutdownDone was not marked as successful by the writer thread", e);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:16,代码来源:XMPPTCPConnection.java

示例10: nextResultOrThrow

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Returns the next available packet. The method call will block until a stanza(/packet) is available or
 * the <tt>timeout</tt> has elapsed. This method does also cancel the PacketCollector.
 * 
 * @param timeout the amount of time to wait for the next stanza(/packet) (in milleseconds).
 * @return the next available packet.
 * @throws NoResponseException if there was no response from the server.
 * @throws XMPPErrorException in case an error response.
 */
public <P extends Stanza> P nextResultOrThrow(long timeout) throws NoResponseException, XMPPErrorException {
    P result = nextResult(timeout);
    cancel();
    if (result == null) {
        throw NoResponseException.newWith(connection, this);
    }

    XMPPErrorException.ifHasErrorThenThrow(result);

    return result;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:21,代码来源:PacketCollector.java

示例11: authenticate

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Performs SASL authentication of the specified user. If SASL authentication was successful
 * then resource binding and session establishment will be performed. This method will return
 * the full JID provided by the server while binding a resource to the connection.<p>
 *
 * The server may assign a full JID with a username or resource different than the requested
 * by this method.
 *
 * @param resource the desired resource.
 * @param cbh the CallbackHandler used to get information from the user
 * @throws IOException 
 * @throws XMPPErrorException 
 * @throws SASLErrorException 
 * @throws SmackException 
 */
public void authenticate(String resource, CallbackHandler cbh) throws IOException,
                XMPPErrorException, SASLErrorException, SmackException {
    SASLMechanism selectedMechanism = selectMechanism();
    if (selectedMechanism != null) {
        currentMechanism = selectedMechanism;
        synchronized (this) {
            currentMechanism.authenticate(connection.getHost(), connection.getServiceName(), cbh);
            try {
                // Wait until SASL negotiation finishes
                wait(connection.getPacketReplyTimeout());
            }
            catch (InterruptedException e) {
                // Ignore
            }
        }

        maybeThrowException();

        if (!authenticationSuccessful) {
            throw NoResponseException.newWith(connection);
        }
    }
    else {
        throw new SmackException(
                        "SASL Authentication failed. No known authentication mechanisims.");
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:43,代码来源:SASLAuthentication.java

示例12: checkIfSuccessOrWaitOrThrow

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Check if this synchronization point is successful or wait the connections reply timeout.
 * @throws NoResponseException if there was no response marking the synchronization point as success or failed.
 * @throws E if there was a failure
 */
public void checkIfSuccessOrWaitOrThrow() throws NoResponseException, E {
    checkIfSuccessOrWait();
    if (state == State.Failure) {
        throw failureException;
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:SynchronizationPoint.java

示例13: checkForResponse

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
/**
 * Check for a response and throw a {@link NoResponseException} if there was none.
 * <p>
 * The exception is thrown, if state is one of 'Initial', 'NoResponse' or 'RequestSent'
 * </p>
 * @throws NoResponseException
 */
private void checkForResponse() throws NoResponseException {
    switch (state) {
    case Initial:
    case NoResponse:
    case RequestSent:
        throw NoResponseException.newWith(connection);
    default:
        // Do nothing
        break;
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:19,代码来源:SynchronizationPoint.java

示例14: getSocket

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
public Socket getSocket(int timeout) throws IOException, InterruptedException,
                TimeoutException, XMPPException, SmackException {
    Socket socket = null;

    // check if stream host is the local SOCKS5 proxy
    if (this.streamHost.getJID().equals(this.connection.get().getUser())) {
        Socks5Proxy socks5Server = Socks5Proxy.getSocks5Proxy();
        socket = socks5Server.getSocket(this.digest);
        if (socket == null) {
            throw new SmackException("target is not connected to SOCKS5 proxy");
        }
    }
    else {
        socket = super.getSocket(timeout);

        try {
            activate();
        }
        catch (XMPPException e1) {
            socket.close();
            throw e1;
        }
        catch (NoResponseException e2) {
            socket.close();
            throw e2;
        }

    }

    return socket;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:32,代码来源:Socks5ClientForInitiator.java

示例15: changeRole

import org.jivesoftware.smack.SmackException.NoResponseException; //导入依赖的package包/类
private void changeRole(String nickname, MUCRole role, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException {
    MUCAdmin iq = new MUCAdmin();
    iq.setTo(room);
    iq.setType(IQ.Type.set);
    // Set the new role.
    MUCItem item = new MUCItem(role, nickname, reason);
    iq.addItem(item);

    connection.createPacketCollectorAndSend(iq).nextResultOrThrow();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:11,代码来源:MultiUserChat.java


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