MessageListener listener = new MessageListener(){
@Override
public void processMessage(Chat chat, Message message){
println message.getBody()
}
}
ConnectionConfiguration cfg = new ConnectionConfiguration("my-pc",5222);
cfg.setSASLAuthenticationEnabled(true);
XMPPConnection con = new XMPPConnection(cfg);
con.connect();
con.login("littlechild","secretpassword");
ChatManager mgr = con.getChatManager();
Chat chat = mgr.createChat("winnenair",listener);
chat.sendMessage("Hello!");
// con.disconnect();
I am using this code to send a message to a user named " winnenair
".
My OpenFire Admin Console does show me (the code) and the user (Spark IM Client) as online. However, when I send a message from the code, it never appears in the IM Client. Both of them are on the same laptop.
Have I done something wrong?
Extra:
Both the users have been added to the roster
The problem is confined to this line:
Chat chat = mgr.createChat("winnenair",listener);
The name " winnenair
" needs to be " winnenair@my-pc
". One needs to append the domain to the username.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.