Package org.jivesoftware.smack.packet

Examples of org.jivesoftware.smack.packet.Packet


        PacketFilter filter = new IdPacketFilter(request.getPacketID());
       
        addPacketListener(listener, filter);
        sendPacket(request);
       
        Packet response = queue.poll(10000, TimeUnit.MILLISECONDS);
        removePacketListener(listener);
       
        return response;
    }
View Full Code Here


    }

    private ModelAndView sendRequestAndGenerateForm(String command, ExtendedXMPPConnection client,
            AdHocCommandData requestCommand) {
        try {
            Packet response = client.sendSync(requestCommand);
           
            StringBuffer htmlForm = new StringBuffer();
            if(response != null) {
                AdHocCommandData responseData = (AdHocCommandData) response;
                DataForm form = responseData.getForm();
View Full Code Here

    SarosPacketCollector collector = transmitter.installReceiver(filter);

    sendWithoutDispatch(msg);

    // receiving automatically removes collector
    Packet packet = transmitter.receive(monitor, collector,
        SXE_TIMEOUT_INTERVAL, true);

    SXEMessage response = ((SXEExtension) packet.getExtension(
        SXEMessage.SXE_TAG, SXEMessage.SXE_XMLNS)).getMessage();
    response.setFrom(msg.getTo());

    return response;
  }
View Full Code Here

        List to = Arrays.asList(new String[]{getBareJID(1)});
        List cc = Arrays.asList(new String[]{getBareJID(2)});
        List bcc = Arrays.asList(new String[]{getBareJID(3)});
        MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc);

        Packet message1 = collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
        assertNotNull("Connection 1 never received the message", message1);
        MultipleRecipientInfo info1 = MultipleRecipientManager.getMultipleRecipientInfo(message1);
        assertNotNull("Message 1 does not contain MultipleRecipientInfo", info1);
        assertFalse("Message 1 should be 'replyable'", info1.shouldNotReply());
        List addresses1 = info1.getTOAddresses();
        assertEquals("Incorrect number of TO addresses", 1, addresses1.size());
        String address1 = ((MultipleAddresses.Address) addresses1.get(0)).getJid();
        assertEquals("Incorrect TO address", getBareJID(1), address1);
        addresses1 = info1.getCCAddresses();
        assertEquals("Incorrect number of CC addresses", 1, addresses1.size());
        address1 = ((MultipleAddresses.Address) addresses1.get(0)).getJid();
        assertEquals("Incorrect CC address", getBareJID(2), address1);

        Packet message2 = collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
        assertNotNull("Connection 2 never received the message", message2);
        MultipleRecipientInfo info2 = MultipleRecipientManager.getMultipleRecipientInfo(message2);
        assertNotNull("Message 2 does not contain MultipleRecipientInfo", info2);
        assertFalse("Message 2 should be 'replyable'", info2.shouldNotReply());
        List addresses2 = info2.getTOAddresses();
        assertEquals("Incorrect number of TO addresses", 1, addresses2.size());
        String address2 = ((MultipleAddresses.Address) addresses2.get(0)).getJid();
        assertEquals("Incorrect TO address", getBareJID(1), address2);
        addresses2 = info2.getCCAddresses();
        assertEquals("Incorrect number of CC addresses", 1, addresses2.size());
        address2 = ((MultipleAddresses.Address) addresses2.get(0)).getJid();
        assertEquals("Incorrect CC address", getBareJID(2), address2);

        Packet message3 = collector3.nextResult(SmackConfiguration.getPacketReplyTimeout());
        assertNotNull("Connection 3 never received the message", message3);
        MultipleRecipientInfo info3 = MultipleRecipientManager.getMultipleRecipientInfo(message3);
        assertNotNull("Message 3 does not contain MultipleRecipientInfo", info3);
        assertFalse("Message 3 should be 'replyable'", info3.shouldNotReply());
        List addresses3 = info3.getTOAddresses();
View Full Code Here

       
        // Send create & join packet.
        connection.sendPacket(requestPrivacy);
       
        // Wait up to a certain number of seconds for a reply.
        Packet privacyAnswer = response.nextResult(SmackConfiguration.getPacketReplyTimeout());
       
        // Stop queuing results
        response.cancel();

        // Interprete the result and answer the privacy only if it is valid
        if (privacyAnswer == null) {
            throw new XMPPException("No response from server.");
        } else if (privacyAnswer.getError() != null) {
            throw new XMPPException(privacyAnswer.getError());
        }
        return privacyAnswer;
  }
View Full Code Here

      chat1.sendMessage(msg);
  }
  catch (Exception e) {
      fail("An error occured sending the message with XHTML");
  }
  Packet packet = chat2.nextResult(2000);
  Message message = (Message) packet;
  assertNotNull("Body is null", message.getBody());
  try {
      xhtmlExtension =
    (XHTMLExtension) message.getExtension(
View Full Code Here

      chat1.sendMessage(msg);
  }
  catch (Exception e) {
      fail("An error occured sending the message with XHTML");
  }
  Packet packet = chat2.nextResult(2000);
  int received = 0;
  Message message = (Message) packet;
  assertNotNull("Body is null", message.getBody());
  try {
      xhtmlExtension =
View Full Code Here

        PacketCollector collector = connection.createPacketCollector(
                new PacketIDFilter(data.getPacketID()));

        connection.sendPacket(data);

        Packet response = collector.nextResult(timeout);

        // Cancel the collector.
        collector.cancel();
        if (response == null) {
            throw new XMPPException("No response from server on status set.");
        }
        if (response.getError() != null) {
            throw new XMPPException(response.getError());
        }

        AdHocCommandData responseData = (AdHocCommandData) response;
        this.sessionID = responseData.getSessionID();
        super.setData(responseData);
View Full Code Here

     * Returns the next available packet from the queue for writing.
     *
     * @return the next packet for writing.
     */
    private Packet nextPacket() {
        Packet packet = null;
        // Wait until there's a packet or we're done.
        while (!done && (packet = queue.poll()) == null) {
            try {
                synchronized (queue) {
                    queue.wait();
View Full Code Here

        try {
            // Open the stream.
            openStream();
            // Write out packets from the queue.
            while (!done && (writerThread == thisThread)) {
                Packet packet = nextPacket();
                if (packet != null) {
                    synchronized (writer) {
                        writer.write(packet.toXML());
                        writer.flush();
                        // Keep track of the last time a stanza was sent to the server
                        lastActive = System.currentTimeMillis();
                    }
                }
            }
            // Flush out the rest of the queue. If the queue is extremely large, it's possible
            // we won't have time to entirely flush it before the socket is forced closed
            // by the shutdown process.
            try {
                synchronized (writer) {
                   while (!queue.isEmpty()) {
                       Packet packet = queue.remove();
                        writer.write(packet.toXML());
                    }
                    writer.flush();
                }
            }
            catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.jivesoftware.smack.packet.Packet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.