I’‘m trying to build a bot using smack, but it doesn’‘t work out… (It’'s the first time I try to receive a message.)
My code which comes from the example:
XMPPConnection.DEBUG_ENABLED = true;
XMPPConnection con;
try {
con = new SSLXMPPConnection(myserver);
con.login(mylogin,mypass);
Chat newChat = con.createChat(mycontact);
Message newMessage = newChat.createMessage();
newMessage.setBody(“Hi, I’'m an annoying parrot-bot! Type something back to me.”);
newChat.sendMessage(newMessage);
while (true) {
// Wait for the next message the user types to us.
Message message = newChat.pollMessage();
if (message == null){
}
else{
System.out.println(message.getBody());
// Send back the same text the other user sent us.
newChat.sendMessage(message.getBody());
}
}
} catch (XMPPException e) {
e.printStackTrace();
}
This doesn’'t work at all, altough the debug tells me it has interpreted my response:
test
What do I do wrong?