powered by Jive Software

I think I have a problem in get message

Hi community,

public class MyChat {

Connection connection;

String user;

MyChat(Connection connection, String user) {

this.connection = connection;

this.user = user;

}

public void Mychat() {

ChatManager chatmanager = connection.getChatManager();

Chat newChat = chatmanager.createChat(user + "@hotmail.com",

new MessageListener() {

@Override

public void processMessage(Chat chat, Message message) {

System.out.println("Received message: " + message);

}

});

Message newMessage = new Message();

newMessage.setBody(“missatge canviat”);

newMessage.setProperty(“favorite color”, “red”);

chatmanager.addChatListener(new ChatManagerListener() {

@Override

public void chatCreated(Chat chat, boolean createdLocally) {

// TODO Auto-generated method stub

if (!createdLocally)

chat.addMessageListener(new MyNewMessageListener());

}

});

try {

newChat.sendMessage(newMessage);

} catch (Exception e) {

// TODO: handle exception

System.out.println(“Error Delivering block”);

}

}

}

public class MyNewMessageListener implements MessageListener {

@Override

public void processMessage(Chat chat, Message message) {

System.out.println("Received message: " + message);

}

}

“call”

OpenFire con = new OpenFire(“prova1”,“prova1”);

OpenFire con2 = new OpenFire(“prova2”,“prova2”);

con.Conect();

con2.Conect();

Only recive :

Received message: org.jivesoftware.smack.packet.Message@f5dc8145

Received message: org.jivesoftware.smack.packet.Message@f5dc7d84

I don’t know if my code is correct for send and get messages

Thanks.

Looks fine for me. Where’s the problem?

you can tell me how work “chatmanager.addChatListener(new ChatManagerListener()”

http://www.igniterealtime.org/builds/smack/docs/latest/documentation/messaging.h tml

I say because works correctly without “chatmanager.addChatListener(new ChatManagerListener()”

and other question is “Received message: org.jivesoftware.smack.packet.Message@f5dc7d84” I need see words the my “newMessage” and not need see link @PathObjectSmack

also Received message: org.jives… takes much time … about 20-30 secounds… not is fast …

chatmanager.addChatListener() is just another method you can use.

If you print the message object, you see the reference obviously.

Use mesage.getBody().

I tried it yesterday and only see “null”

I tried .allMethods

and delay 20-30 secounds for recive … why ?

solved