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


Java XMPPErrorException.ifHasErrorThenThrow方法代码示例

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


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

示例1: nextResultOrThrow

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入方法依赖的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

示例2: initiateIncomingStream

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入方法依赖的package包/类
protected final IQ initiateIncomingStream(final XMPPConnection connection, StreamInitiation initiation)
                throws NoResponseException, XMPPErrorException, NotConnectedException {
    final StreamInitiation response = createInitiationAccept(initiation,
            getNamespaces());

    newStreamInitiation(initiation.getFrom(), initiation.getSessionID());

    final String eventKey = initiation.getFrom().toString() + '\t' + initiation.getSessionID();
    IQ streamMethodInitiation;
    try {
        streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getPacketReplyTimeout(), new Callback<NotConnectedException>() {
            @Override
            public void action() throws NotConnectedException {
                connection.sendStanza(response);
            }
        });
    }
    catch (InterruptedException e) {
        // TODO remove this try/catch once merged into 4.2's master branch
        throw new IllegalStateException(e);
    }

    if (streamMethodInitiation == null) {
        throw NoResponseException.newWith(connection);
    }
    XMPPErrorException.ifHasErrorThenThrow(streamMethodInitiation);
    return streamMethodInitiation;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:29,代码来源:StreamNegotiator.java

示例3: sendStanzaWithResponseCallback

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入方法依赖的package包/类
@Override
public void sendStanzaWithResponseCallback(Stanza stanza, final StanzaFilter replyFilter,
                final StanzaListener callback, final ExceptionCallback exceptionCallback,
                long timeout) throws NotConnectedException {
    Objects.requireNonNull(stanza, "stanza must not be null");
    // While Smack allows to add PacketListeners with a PacketFilter value of 'null', we
    // disallow it here in the async API as it makes no sense
    Objects.requireNonNull(replyFilter, "replyFilter must not be null");
    Objects.requireNonNull(callback, "callback must not be null");

    final StanzaListener packetListener = new StanzaListener() {
        @Override
        public void processPacket(Stanza packet) throws NotConnectedException {
            try {
                XMPPErrorException.ifHasErrorThenThrow(packet);
                callback.processPacket(packet);
            }
            catch (XMPPErrorException e) {
                if (exceptionCallback != null) {
                    exceptionCallback.processException(e);
                }
            }
            finally {
                removeAsyncStanzaListener(this);
            }
        }
    };
    removeCallbacksService.schedule(new Runnable() {
        @Override
        public void run() {
            boolean removed = removeAsyncStanzaListener(packetListener);
            // If the packetListener got removed, then it was never run and
            // we never received a response, inform the exception callback
            if (removed && exceptionCallback != null) {
                exceptionCallback.processException(NoResponseException.newWith(AbstractXMPPConnection.this, replyFilter));
            }
        }
    }, timeout, TimeUnit.MILLISECONDS);
    addAsyncStanzaListener(packetListener, replyFilter);
    sendStanza(stanza);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:42,代码来源:AbstractXMPPConnection.java

示例4: pollResultOrThrow

import org.jivesoftware.smack.XMPPException.XMPPErrorException; //导入方法依赖的package包/类
/**
 * Polls to see if a stanza(/packet) is currently available and returns it, or
 * immediately returns <tt>null</tt> if no packets are currently in the
 * result queue.
 * <p>
 * Throws an XMPPErrorException in case the polled stanzas did contain an XMPPError.
 * </p>
 * 
 * @return the next available packet.
 * @throws XMPPErrorException in case an error response.
 */
public <P extends Stanza> P pollResultOrThrow() throws XMPPErrorException {
    P result = pollResult();
    if (result != null) {
        XMPPErrorException.ifHasErrorThenThrow(result);
    }
    return result;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:19,代码来源:PacketCollector.java


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