當前位置: 首頁>>代碼示例>>Java>>正文


Java IQ.setFrom方法代碼示例

本文整理匯總了Java中org.jivesoftware.smack.packet.IQ.setFrom方法的典型用法代碼示例。如果您正苦於以下問題:Java IQ.setFrom方法的具體用法?Java IQ.setFrom怎麽用?Java IQ.setFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jivesoftware.smack.packet.IQ的用法示例。


在下文中一共展示了IQ.setFrom方法的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: createResultIQ

import org.jivesoftware.smack.packet.IQ; //導入方法依賴的package包/類
/**
 * Returns a result IQ.
 * 
 * @param from the senders JID
 * @param to the recipients JID
 * @return a result IQ
 */
public static IQ createResultIQ(String from, String to) {
    IQ result = new EmptyResultIQ();
    result.setType(IQ.Type.result);
    result.setFrom(from);
    result.setTo(to);
    return result;
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:15,代碼來源:IBBPacketUtils.java

示例3: shouldFailIfActivateSocks5ProxyFails

import org.jivesoftware.smack.packet.IQ; //導入方法依賴的package包/類
/**
 * If the initiator can connect to a SOCKS5 proxy but activating the stream fails an exception
 * should be thrown.
 * 
 * @throws Exception should not happen
 */
@Test
public void shouldFailIfActivateSocks5ProxyFails() throws Exception {

    // build error response as reply to the stream activation
    XMPPError xmppError = new XMPPError(XMPPError.Condition.internal_server_error);
    IQ error = new ErrorIQ(xmppError);
    error.setFrom(proxyJID);
    error.setTo(initiatorJID);

    protocol.addResponse(error, Verification.correspondingSenderReceiver,
                    Verification.requestTypeSET);

    // start a local SOCKS5 proxy
    Socks5TestProxy socks5Proxy = Socks5TestProxy.getProxy(proxyPort);
    socks5Proxy.start();

    StreamHost streamHost = new StreamHost(proxyJID,
                    socks5Proxy.getAddress(), socks5Proxy.getPort());

    // create digest to get the socket opened by target
    String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID);

    Socks5ClientForInitiator socks5Client = new Socks5ClientForInitiator(streamHost, digest,
                    connection, sessionID, targetJID);

    try {

        socks5Client.getSocket(10000);

        fail("exception should be thrown");
    }
    catch (XMPPErrorException e) {
        assertTrue(XMPPError.Condition.internal_server_error.equals(e.getXMPPError().getCondition()));
        protocol.verifyAll();
    }

    socks5Proxy.stop();
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:45,代碼來源:Socks5ClientForInitiatorTest.java

示例4: shouldSuccessfullyEstablishConnectionAndActivateSocks5Proxy

import org.jivesoftware.smack.packet.IQ; //導入方法依賴的package包/類
/**
 * Target and initiator should successfully connect to a "remote" SOCKS5 proxy and the initiator
 * activates the bytestream.
 * 
 * @throws Exception should not happen
 */
@Test
public void shouldSuccessfullyEstablishConnectionAndActivateSocks5Proxy() throws Exception {

    // build activation confirmation response
    IQ activationResponse = new EmptyResultIQ();

    activationResponse.setFrom(proxyJID);
    activationResponse.setTo(initiatorJID);

    protocol.addResponse(activationResponse, Verification.correspondingSenderReceiver,
                    Verification.requestTypeSET, new Verification<Bytestream, IQ>() {

                        public void verify(Bytestream request, IQ response) {
                            // verify that the correct stream should be activated
                            assertNotNull(request.getToActivate());
                            assertEquals(targetJID, request.getToActivate().getTarget());
                        }

                    });

    // start a local SOCKS5 proxy
    Socks5TestProxy socks5Proxy = Socks5TestProxy.getProxy(proxyPort);
    socks5Proxy.start();

    StreamHost streamHost = new StreamHost(proxyJID,
                    socks5Proxy.getAddress(), socks5Proxy.getPort());

    // create digest to get the socket opened by target
    String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID);

    Socks5ClientForInitiator socks5Client = new Socks5ClientForInitiator(streamHost, digest,
                    connection, sessionID, targetJID);

    Socket initiatorSocket = socks5Client.getSocket(10000);
    InputStream in = initiatorSocket.getInputStream();

    Socket targetSocket = socks5Proxy.getSocket(digest);
    OutputStream out = targetSocket.getOutputStream();

    // verify test data
    for (int i = 0; i < 10; i++) {
        out.write(i);
        assertEquals(i, in.read());
    }

    protocol.verifyAll();

    initiatorSocket.close();
    targetSocket.close();
    socks5Proxy.stop();

}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:59,代碼來源:Socks5ClientForInitiatorTest.java

示例5: sendRoomInvitation

import org.jivesoftware.smack.packet.IQ; //導入方法依賴的package包/類
/**
 * Invites a user or agent to an existing session support. The provided invitee's JID can be of
 * a user, an agent, a queue or a workgroup. In the case of a queue or a workgroup the workgroup service
 * will decide the best agent to receive the invitation.<p>
 *
 * This method will return either when the service returned an ACK of the request or if an error occured
 * while requesting the invitation. After sending the ACK the service will send the invitation to the target
 * entity. When dealing with agents the common sequence of offer-response will be followed. However, when
 * sending an invitation to a user a standard MUC invitation will be sent.<p>
 *
 * The agent or user that accepted the offer <b>MUST</b> join the room. Failing to do so will make
 * the invitation to fail. The inviter will eventually receive a message error indicating that the invitee
 * accepted the offer but failed to join the room.
 *
 * Different situations may lead to a failed invitation. Possible cases are: 1) all agents rejected the
 * offer and ther are no agents available, 2) the agent that accepted the offer failed to join the room or
 * 2) the user that received the MUC invitation never replied or joined the room. In any of these cases
 * (or other failing cases) the inviter will get an error message with the failed notification.
 *
 * @param type type of entity that will get the invitation.
 * @param invitee JID of entity that will get the invitation.
 * @param sessionID ID of the support session that the invitee is being invited.
 * @param reason the reason of the invitation.
 * @throws XMPPErrorException if the sender of the invitation is not an agent or the service failed to process
 *         the request.
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */
public void sendRoomInvitation(RoomInvitation.Type type, String invitee, String sessionID, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException
        {
    final RoomInvitation invitation = new RoomInvitation(type, invitee, sessionID, reason);
    IQ iq = new RoomInvitation.RoomInvitationIQ(invitation);
    iq.setType(IQ.Type.set);
    iq.setTo(workgroupJID);
    iq.setFrom(connection.getUser());

    connection.createPacketCollectorAndSend(iq).nextResultOrThrow();
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:39,代碼來源:AgentSession.java

示例6: sendRoomTransfer

import org.jivesoftware.smack.packet.IQ; //導入方法依賴的package包/類
/**
 * Transfer an existing session support to another user or agent. The provided invitee's JID can be of
 * a user, an agent, a queue or a workgroup. In the case of a queue or a workgroup the workgroup service
 * will decide the best agent to receive the invitation.<p>
 *
 * This method will return either when the service returned an ACK of the request or if an error occured
 * while requesting the transfer. After sending the ACK the service will send the invitation to the target
 * entity. When dealing with agents the common sequence of offer-response will be followed. However, when
 * sending an invitation to a user a standard MUC invitation will be sent.<p>
 *
 * Once the invitee joins the support room the workgroup service will kick the inviter from the room.<p>
 *
 * Different situations may lead to a failed transfers. Possible cases are: 1) all agents rejected the
 * offer and there are no agents available, 2) the agent that accepted the offer failed to join the room
 * or 2) the user that received the MUC invitation never replied or joined the room. In any of these cases
 * (or other failing cases) the inviter will get an error message with the failed notification.
 *
 * @param type type of entity that will get the invitation.
 * @param invitee JID of entity that will get the invitation.
 * @param sessionID ID of the support session that the invitee is being invited.
 * @param reason the reason of the invitation.
 * @throws XMPPErrorException if the sender of the invitation is not an agent or the service failed to process
 *         the request.
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */
public void sendRoomTransfer(RoomTransfer.Type type, String invitee, String sessionID, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException
        {
    final RoomTransfer transfer = new RoomTransfer(type, invitee, sessionID, reason);
    IQ iq = new RoomTransfer.RoomTransferIQ(transfer);
    iq.setType(IQ.Type.set);
    iq.setTo(workgroupJID);
    iq.setFrom(connection.getUser());

    connection.createPacketCollectorAndSend(iq).nextResultOrThrow();
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:37,代碼來源:AgentSession.java

示例7: createErrorIQ

import org.jivesoftware.smack.packet.IQ; //導入方法依賴的package包/類
/**
 * Returns an error IQ.
 * 
 * @param from the senders JID
 * @param to the recipients JID
 * @param xmppError the XMPP error
 * @return an error IQ
 */
public static IQ createErrorIQ(String from, String to, XMPPError xmppError) {
    IQ errorIQ = new ErrorIQ(xmppError);
    errorIQ.setType(IQ.Type.error);
    errorIQ.setFrom(from);
    errorIQ.setTo(to);
    return errorIQ;
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:16,代碼來源:IBBPacketUtils.java

示例8: createActivationConfirmation

import org.jivesoftware.smack.packet.IQ; //導入方法依賴的package包/類
/**
 * Returns a response IQ for a activation request to the proxy.
 * 
 * @param from JID of the proxy
 * @param to JID of the client who wants to activate the SOCKS5 Bytestream
 * @return response IQ for a activation request to the proxy
 */
public static IQ createActivationConfirmation(String from, String to) {
    IQ response = new EmptyResultIQ();
    response.setFrom(from);
    response.setTo(to);
    return response;
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:14,代碼來源:Socks5PacketUtils.java


注:本文中的org.jivesoftware.smack.packet.IQ.setFrom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。