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


Java IQ.createResultIQ方法代码示例

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


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

示例1: sendStanza

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
@Override
public void sendStanza(Stanza packet) throws NotConnectedException {
    super.sendStanza(packet);

    if (packet instanceof IQ && !timeout) {
        timeout = false;
        // Set reply packet to match one being sent. We haven't started the
        // other thread yet so this is still safe.
        IQ replyPacket = replyQ.peek();

        // If no reply has been set via addIQReply, then we create a simple reply
        if (replyPacket == null) {
            replyPacket = IQ.createResultIQ((IQ) packet);
            replyQ.add(replyPacket);
        }
        replyPacket.setStanzaId(packet.getStanzaId());
        replyPacket.setFrom(packet.getTo());
        replyPacket.setTo(packet.getFrom());
        replyPacket.setType(Type.result);

        new ProcessQueue(replyQ).start();
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:24,代码来源:ThreadedDummyConnection.java

示例2: closeByPeer

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
/**
 * This method is invoked if a request to close the In-Band Bytestream has been received.
 * 
 * @param closeRequest the close request from the remote peer
 * @throws NotConnectedException 
 */
protected void closeByPeer(Close closeRequest) throws NotConnectedException {

    /*
     * close streams without flushing them, because stream is already considered closed on the
     * remote peers side
     */
    this.inputStream.closeInternal();
    this.inputStream.cleanup();
    this.outputStream.closeInternal(false);

    // acknowledge close request
    IQ confirmClose = IQ.createResultIQ(closeRequest);
    this.connection.sendStanza(confirmClose);

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

示例3: createAck

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
/**
 * Acknowledge a IQ packet.
 * 
 * @param iq
 *            The IQ to acknowledge
 */
public IQ createAck(IQ iq) {
    IQ result = null;

    if (iq != null) {
        // Don't acknowledge ACKs, errors...
        if (iq.getType().equals(IQ.Type.set)) {
            IQ ack = IQ.createResultIQ(iq);

            // No! Don't send it.  Let it flow to the normal way IQ results get processed and sent.
            // getConnection().sendStanza(ack);
            result = ack;
        }
    }
    return result;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:22,代码来源:JingleSession.java

示例4: run

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
public void run() {
    try {
        while (true) {
            final Stanza packet = connection.getSentPacket();
            if (packet instanceof RosterPacket && ((IQ) packet).getType() == Type.set) {
                final RosterPacket rosterRequest = (RosterPacket) packet;

                // Prepare and process the roster push
                final RosterPacket rosterPush = new RosterPacket();
                final Item item = rosterRequest.getRosterItems().iterator().next();
                if (item.getItemType() != ItemType.remove) {
                    item.setItemType(ItemType.none);
                }
                rosterPush.setType(Type.set);
                rosterPush.setTo(connection.getUser());
                rosterPush.addRosterItem(item);
                connection.processPacket(rosterPush);

                // Create and process the IQ response
                final IQ response = IQ.createResultIQ(rosterRequest);
                connection.processPacket(response);

                // Verify the roster update request
                assertSame("A roster set MUST contain one and only one <item/> element.",
                        1,
                        rosterRequest.getRosterItemCount());
                verifyUpdateRequest(rosterRequest);
                break;
            }
        }
    }
    catch (Throwable e) {
        exception = e;
        fail(e.getMessage());
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:37,代码来源:RosterTest.java

示例5: answerWithEmptyRosterResult

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
private void answerWithEmptyRosterResult() throws InterruptedException {
    // We expect that the roster request is the only packet sent. This is not part of the specification,
    // but a shortcut in the test implementation.
    Stanza sentPacket = connection.getSentPacket();
    if (sentPacket instanceof RosterPacket) {
        final IQ emptyIQ = IQ.createResultIQ((RosterPacket)sentPacket);
        connection.processPacket(emptyIQ);
    } else {
        assertTrue("Expected to get a RosterPacket ", false);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:RosterVersioningTest.java

示例6: accept

import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
/**
 * Accepts the In-Band Bytestream open request and returns the session to
 * send/receive data.
 * 
 * @return the session to send/receive data
 * @throws NotConnectedException 
 */
public InBandBytestreamSession accept() throws NotConnectedException {
    XMPPConnection connection = this.manager.getConnection();

    // create In-Band Bytestream session and store it
    InBandBytestreamSession ibbSession = new InBandBytestreamSession(connection,
                    this.byteStreamRequest, this.byteStreamRequest.getFrom());
    this.manager.getSessions().put(this.byteStreamRequest.getSessionID(), ibbSession);

    // acknowledge request
    IQ resultIQ = IQ.createResultIQ(this.byteStreamRequest);
    connection.sendStanza(resultIQ);

    return ibbSession;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:22,代码来源:InBandBytestreamRequest.java

示例7: 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

示例8: 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


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