Package org.jivesoftware.smack.packet

Examples of org.jivesoftware.smack.packet.Message


    public void testSendMessageToRoom() throws Exception {
        chat.join("Nick");
        chat2.join("Nick2");

        chat.sendMessage("Fooo");
        Message message = chat.nextMessage(5000);

        assertNotNull(message);
        assertEquals("Fooo", message.getBody());
        assertEquals(ROOM_JID + "/Nick", message.getFrom());
        assertEquals(TEST_USERNAME1, EntityImpl.parse(message.getTo()).getBareJID().getFullQualifiedName());

        message = chat2.nextMessage(5000);
        assertNotNull(message);
        assertEquals("Fooo", message.getBody());
        assertEquals(ROOM_JID + "/Nick", message.getFrom());
        assertEquals(TEST_USERNAME2, EntityImpl.parse(message.getTo()).getBareJID().getFullQualifiedName());
    }
View Full Code Here


     * Sending
     */

    @Override
    protected void onSendBeforeWrite(WebServiceMessage message) throws IOException {
        responseMessage = new Message(requestMessage.getFrom(), Message.Type.chat);
        responseMessage.setFrom(connection.getUser());
        responseMessage.setThread(requestMessage.getThread());
    }
View Full Code Here

    protected XmppSenderConnection(XMPPConnection connection, String to, String thread) {
        Assert.notNull(connection, "'connection' must not be null");
        Assert.hasLength(to, "'to' must not be empty");
        Assert.hasLength(thread, "'thread' must not be empty");
        this.connection = connection;
        this.requestMessage = new Message(to, Message.Type.chat);
        this.requestMessage.setThread(thread);
    }
View Full Code Here

        @Override
        public void processPacket(Packet packet) {
            logger.info("Received " + packet);
            if (packet instanceof Message) {
                Message message = (Message) packet;
                try {
                    XmppReceiverConnection wsConnection = new XmppReceiverConnection(connection, message);
                    wsConnection.setMessageEncoding(messageEncoding);
                    handleConnection(wsConnection);
                }
View Full Code Here

            ChatManager chatmanager = connection.getChatManager();
            Chat chat = chatmanager.createChat(toUser, null);

            try {
                // google bounces back the default message types, you must use chat
                Message msg = new Message(toUser, Message.Type.chat);
                msg.setBody(text);
                chat.sendMessage(msg);
                System.out.println("Message Sended");
            } catch (XMPPException e) {
                System.out.println("Failed to send message");
                // handle this how?
View Full Code Here

    // Implementation methods
    //-------------------------------------------------------------------------
    protected void process(MessageExchange messageExchange, NormalizedMessage normalizedMessage) throws MessagingException {
        try {
            Message message = chat.createMessage();
            getMarshaler().fromNMS(message, normalizedMessage);
            chat.sendMessage(message);
            done(messageExchange);
        }
        catch (TransformerException e) {
View Full Code Here

    // Implementation methods
    //-------------------------------------------------------------------------
    protected void process(MessageExchange messageExchange, NormalizedMessage normalizedMessage) throws MessagingException {
        try {
            Message message = chat.createMessage();
            getMarshaler().fromNMS(message, normalizedMessage);
            chat.sendMessage(message);
            done(messageExchange);
        }
        catch (TransformerException e) {
View Full Code Here

     * @throws MessagingException
     */
    public void toNMS(NormalizedMessage normalizedMessage, Packet packet) throws MessagingException {
        addNmsProperties(normalizedMessage, packet);
        if (packet instanceof Message) {
            Message message = (Message) packet;
            Source source = sourceMarshaler.asSource(message.getBody());
            normalizedMessage.setContent(source);
        }

        // lets add the packet to the NMS
        normalizedMessage.setProperty("org.servicemix.jabber.packet", packet);
View Full Code Here

            }
        });

        for (int i = 0; i < 10; i++) {
            System.out.println("Sending message: " + i);
            Message message = new Message("consumer");
            message.setType(Message.Type.chat);
            message.setBody("Hello from producer, message # " + i);
            chat.sendMessage(message);
        }
        System.out.println("Sent all messages!");

        Thread.sleep(sleepTime);
View Full Code Here

        MultiUserChat producerMuc = new MultiUserChat(producerCon, "muc-test");
        producerMuc.join("producer");

        for (int i = 0; i < 10; i++) {
            System.out.println("Sending message: " + i);
            Message message = producerMuc.createMessage();
            message.setBody("Hello from producer, message # " + i);
            producerMuc.sendMessage(message);
        }
        System.out.println("Sent all messages!");

        Thread.sleep(sleepTime);
View Full Code Here

TOP

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

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.