Hello All,
i ve just tried to use Smack … my code built from common samples. Please look:
import org.jivesoftware.smack.*;
package keos.cps.jabber;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.packet.Message;
public class KeosMessage {
public static void main(String[] args) throws Exception {
ConnectionConfiguration config = new ConnectionConfiguration(“talk.google.com”, 5222,“googlemail.com”);
config.setSASLAuthenticationEnabled(true);
XMPPConnection connection = new XMPPConnection(config);
connection.connect();
connection.login("myaccount@googlemail.com", "xxxxxxxxxxx");
ChatManager chatmanager = connection.getChatManager();
Chat chat = chatmanager.createChat(“Dzmitry.Ilyin”, new MessageListener() {
public void processMessage(Chat arg0, Message arg1) {
System.out.println("Message ‘“arg1.getBody()”’ recieved from "+arg1.getFrom());
}
});
String messagetext=“test message text”;
chat.sendMessage(messagetext);
System.out.println("Message ‘“messagetext”’ sent to "+chat.getParticipant());
Thread.sleep(10000);
}
}
Program output is:
Message ‘test message text’ sent to Dzmitry.Ilyin
Message ‘test message text’ recieved from Dzmitry.Ilyin
It looks like it sending messages to itself. But message sender is other! Expected recipient Dzmitry.Ilyin does not recieve message at all on his Google Talk normal client. Please help if you understand what is going on. Many thanks!
Dzmitry