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.