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


Java IQ.createErrorResponse方法代码示例

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


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

示例1: createJingleError

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
/**
 * Complete and send an error. Complete all the null fields in an IQ error
 * reponse, using the sesssion information we have or some info from the
 * incoming packet.
 * 
 * @param iq
 *            The Jingle stanza(/packet) we are responing to
 * @param jingleError
 *            the IQ stanza(/packet) we want to complete and send
 */
public IQ createJingleError(IQ iq, JingleError jingleError) {
    IQ errorPacket = null;
    if (jingleError != null) {
        // TODO This is wrong according to XEP-166 § 10, but this jingle implementation is deprecated anyways
        XMPPError error = new XMPPError(XMPPError.Condition.undefined_condition, jingleError);

        errorPacket = IQ.createErrorResponse(iq, error);

        // Fill in the fields with the info from the Jingle packet
        errorPacket.setStanzaId(iq.getStanzaId());
        errorPacket.setError(error);
        //            errorPacket.addExtension(jingleError);

        // NO! Let the normal state machinery do all of the sending.
        // getConnection().sendStanza(perror);
        LOGGER.severe("Error sent: " + errorPacket.toXML());
    }
    return errorPacket;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:30,代码来源:JingleSession.java

示例2: cancelRequest

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
/**
 * Cancels the SOCKS5 Bytestream request by sending an error to the initiator and building a
 * XMPP exception.
 * @throws XMPPErrorException 
 * @throws NotConnectedException 
 */
private void cancelRequest() throws XMPPErrorException, NotConnectedException {
    String errorMessage = "Could not establish socket with any provided host";
    XMPPError error = XMPPError.from(XMPPError.Condition.item_not_found, errorMessage);
    IQ errorIQ = IQ.createErrorResponse(this.bytestreamRequest, error);
    this.manager.getConnection().sendStanza(errorIQ);
    throw new XMPPErrorException(errorMessage, error);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:14,代码来源:Socks5BytestreamRequest.java

示例3: rejectIncomingFileTransfer

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
/**
 * Reject an incoming file transfer.
 * <p>
 * Specified in XEP-95 4.2 and 3.2 Example 8
 * </p>
 * @param request
 * @throws NotConnectedException
 */
protected void rejectIncomingFileTransfer(FileTransferRequest request) throws NotConnectedException {
	StreamInitiation initiation = request.getStreamInitiation();

       // Reject as specified in XEP-95 4.2. Note that this is not to be confused with the Socks 5
       // Bytestream rejection as specified in XEP-65 5.3.1 Example 13, which says that
       // 'not-acceptable' should be returned. This is done by Smack in
       // Socks5BytestreamManager.replyRejectPacket(IQ).
       IQ rejection = IQ.createErrorResponse(initiation, new XMPPError(
                       XMPPError.Condition.forbidden));
       connection().sendStanza(rejection);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:20,代码来源:FileTransferManager.java

示例4: handleIQRequest

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
@Override
public IQ handleIQRequest(IQ iqRequest) {
    final XMPPConnection connection = connection();
    RosterPacket rosterPacket = (RosterPacket) iqRequest;

    // Roster push (RFC 6121, 2.1.6)
    // A roster push with a non-empty from not matching our address MUST be ignored
    String jid = XmppStringUtils.parseBareJid(connection.getUser());
    String from = rosterPacket.getFrom();
    if (from != null && !from.equals(jid)) {
        LOGGER.warning("Ignoring roster push with a non matching 'from' ourJid='" + jid + "' from='" + from
                        + "'");
        return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.service_unavailable));
    }

    // A roster push must contain exactly one entry
    Collection<Item> items = rosterPacket.getRosterItems();
    if (items.size() != 1) {
        LOGGER.warning("Ignoring roster push with not exaclty one entry. size=" + items.size());
        return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.bad_request));
    }

    Collection<String> addedEntries = new ArrayList<String>();
    Collection<String> updatedEntries = new ArrayList<String>();
    Collection<String> deletedEntries = new ArrayList<String>();
    Collection<String> unchangedEntries = new ArrayList<String>();

    // We assured above that the size of items is exaclty 1, therefore we are able to
    // safely retrieve this single item here.
    Item item = items.iterator().next();
    RosterEntry entry = new RosterEntry(item.getUser(), item.getName(),
                    item.getItemType(), item.getItemStatus(), Roster.this, connection);
    String version = rosterPacket.getVersion();

    if (item.getItemType().equals(RosterPacket.ItemType.remove)) {
        deleteEntry(deletedEntries, entry);
        if (rosterStore != null) {
            rosterStore.removeEntry(entry.getUser(), version);
        }
    }
    else if (hasValidSubscriptionType(item)) {
        addUpdateEntry(addedEntries, updatedEntries, unchangedEntries, item, entry);
        if (rosterStore != null) {
            rosterStore.addEntry(item, version);
        }
    }

    removeEmptyGroups();

    // Fire event for roster listeners.
    fireRosterChangedEvent(addedEntries, updatedEntries, deletedEntries);

    return IQ.createResultIQ(rosterPacket);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:55,代码来源:Roster.java

示例5: getDataPacketListener

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
protected StanzaListener getDataPacketListener() {
    return new StanzaListener() {

        private long lastSequence = -1;

        public void processPacket(Stanza packet) throws NotConnectedException {
            // get data packet extension
            DataPacketExtension data = ((Data) packet).getDataPacketExtension();

            /*
             * check if sequence was not used already (see XEP-0047 Section 2.2)
             */
            if (data.getSeq() <= this.lastSequence) {
                IQ unexpectedRequest = IQ.createErrorResponse((IQ) packet, new XMPPError(
                                XMPPError.Condition.unexpected_request));
                connection.sendStanza(unexpectedRequest);
                return;

            }

            // check if encoded data is valid (see XEP-0047 Section 2.2)
            if (data.getDecodedData() == null) {
                // data is invalid; respond with bad-request error
                IQ badRequest = IQ.createErrorResponse((IQ) packet, new XMPPError(
                                XMPPError.Condition.bad_request));
                connection.sendStanza(badRequest);
                return;
            }

            // data is valid; add to data queue
            dataQueue.offer(data);

            // confirm IQ
            IQ confirmData = IQ.createResultIQ((IQ) packet);
            connection.sendStanza(confirmData);

            // set last seen sequence
            this.lastSequence = data.getSeq();
            if (this.lastSequence == 65535) {
                this.lastSequence = -1;
            }

        }

    };
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:47,代码来源:InBandBytestreamSession.java

示例6: replyRejectPacket

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
/**
 * Responses to the given IQ packet's sender with an XMPP error that an In-Band Bytestream is
 * not accepted.
 * 
 * @param request IQ stanza(/packet) that should be answered with a not-acceptable error
 * @throws NotConnectedException 
 */
protected void replyRejectPacket(IQ request) throws NotConnectedException {
    XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
    IQ error = IQ.createErrorResponse(request, xmppError);
    this.connection.sendStanza(error);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:InBandBytestreamManager.java

示例7: replyResourceConstraintPacket

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
/**
 * Responses to the given IQ packet's sender with an XMPP error that an In-Band Bytestream open
 * request is rejected because its block size is greater than the maximum allowed block size.
 * 
 * @param request IQ stanza(/packet) that should be answered with a resource-constraint error
 * @throws NotConnectedException 
 */
protected void replyResourceConstraintPacket(IQ request) throws NotConnectedException {
    XMPPError xmppError = new XMPPError(XMPPError.Condition.resource_constraint);
    IQ error = IQ.createErrorResponse(request, xmppError);
    this.connection.sendStanza(error);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:InBandBytestreamManager.java

示例8: replyItemNotFoundPacket

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
/**
 * Responses to the given IQ packet's sender with an XMPP error that an In-Band Bytestream
 * session could not be found.
 * 
 * @param request IQ stanza(/packet) that should be answered with a item-not-found error
 * @throws NotConnectedException 
 */
protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException {
    XMPPError xmppError = new XMPPError(XMPPError.Condition.item_not_found);
    IQ error = IQ.createErrorResponse(request, xmppError);
    this.connection.sendStanza(error);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:InBandBytestreamManager.java

示例9: replyRejectPacket

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
/**
 * Responses to the given packet's sender with an XMPP error that a SOCKS5 Bytestream is not
 * accepted.
 * <p>
 * Specified in XEP-65 5.3.1 (Example 13)
 * </p>
 * 
 * @param packet Stanza(/Packet) that should be answered with a not-acceptable error
 * @throws NotConnectedException 
 */
protected void replyRejectPacket(IQ packet) throws NotConnectedException {
    XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
    IQ errorIQ = IQ.createErrorResponse(packet, xmppError);
    connection().sendStanza(errorIQ);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:16,代码来源:Socks5BytestreamManager.java


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