The following snippet is picked out of a JIRA plugin I'm writing to (hopefully) notify people (co-workers) via an IM (gchat in my case) when they've been @mentioned on a JIRA ticket.
import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.ChatManager;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.MessageListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message;
ConnectionConfiguration config = new ConnectionConfiguration(<server>, <port>, <domain>);
XMPPConnection connection = New XMPPConnection(config);
connection.connect();
connection.login(someone@domain_a.com, <password>);
ChatManager chatManager = connection.getChatManager();
Chat chat = chatManager.createChat(someone@domain_b, new MessageListener() {
public void processMessage(Chat chat, Message msg) {
System.out.println("Received message "+ msg);
}
});
chat.sendMessage(<msg>);
My issue is that I'm able to send the IM notifications to users that share the domain of the user who was authenticated at the line:
connection.login(someone@domain_a.com, <password>);
But not others - eg: I can send from somone@domain_a.com to someon_else@domain_a.com but NOT able to send it to someone_else@domain_b.com...
Any help is appreciated. Cheers,