Package org.jivesoftware.smack.packet

Examples of org.jivesoftware.smack.packet.Packet


        PacketCollector pc = conn2.createPacketCollector(new PacketTypeFilter(Message.class));
       
        conn2.login(XMPP_LOGIN2, XMPP_PASSWORD2);

        Packet p = pc.nextResult();

        TestStringDocument result = instance.getExtension(p);
        assertEquals(TEST_STRING1, result.getTestString());

        conn2.disconnect();
View Full Code Here


    /**
     * Test of put and get methods of class SimpleMapper with XMLString.
     */
    @Test
    public void testPutGetXmlString() throws Exception {
        Packet packet = new Message();
        SimpleMapper<TestStringDocument> instance = new SimpleMapper(TestStringDocument.class);
        instance.addExtension(packet, testXmlString1);
        TestStringDocument result = instance.getExtension(packet);
        assertEquals("Get must return value which was put",
                     result.getTestString(), TEST_STRING1);
View Full Code Here

    /**
     * Test of get method for non-existent extension.
     */
    @Test
    public void testGetNonExisted1() throws Exception {
        Packet packet = new Message();
        SimpleMapper<TestStringDocument> instance = new SimpleMapper(TestStringDocument.class);
        TestStringDocument result = instance.getExtension(packet);
        assertNull("Extension was not put, so result of get must be null",
                result);
    }
View Full Code Here

            response = sc.evaluateChallenge(Base64.decode(challenge));
        } else {
            response = sc.evaluateChallenge(new byte[0]);
        }

        Packet responseStanza;

        if (response == null) {
            responseStanza = new Response();
        } else {
            responseStanza = new Response(Base64.encodeBytes(response, Base64.DONT_BREAK_LINES));
View Full Code Here

        setType(IQ.Type.SET);
        setFrom(connection.getUser());
        PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(getPacketID()));
        connection.sendPacket(this);

        Packet response = collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

        // 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());
        }
    }
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

        buf.append("<transcript xmlns=\"http://jivesoftware.com/protocol/workgroup\" sessionID=\"")
                .append(sessionID)
                .append("\">");

        for (Iterator it=packets.iterator(); it.hasNext();) {
            Packet packet = (Packet) it.next();
            buf.append(packet.toXML());
        }

        buf.append("</transcript>");

        return buf.toString();
View Full Code Here

        si.setType(IQ.Type.SET);

        PacketCollector collector = connection
                .createPacketCollector(new PacketIDFilter(si.getPacketID()));
        connection.sendPacket(si);
        Packet siResponse = collector.nextResult(responseTimeout);
        collector.cancel();

        if (siResponse instanceof IQ) {
            IQ iqResponse = (IQ) siResponse;
            if (iqResponse.getType().equals(IQ.Type.RESULT)) {
View Full Code Here

        }

    }

    public InputStream createIncomingStream(StreamInitiation initiation) throws XMPPException {
        Packet streamInitiation = initiateIncomingStream(connection, initiation);
        return negotiateIncomingStream(streamInitiation);
    }
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.