简体   繁体   English

Smack:无法发送使用“ Chat chat = mgr.createChat(” winnenair”,listener);”创建的聊天消息。

[英]Smack: Unable to send a message with a Chat created with “Chat chat = mgr.createChat(”winnenair“,listener);”

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 ". 我正在使用此代码向名为“ winnenair ”的用户发送消息。

My OpenFire Admin Console does show me (the code) and the user (Spark IM Client) as online. 我的OpenFire管理控制台确实将我(代码)和用户(Spark IM Client)显示为在线。 However, when I send a message from the code, it never appears in the IM Client. 但是,当我从代码发送消息时,它永远不会出现在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 ". 名称“ winnenair ”必须为“ winnenair@my-pc ”。 One needs to append the domain to the username. 需要将域附加到用户名上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM