0
我使用庫smack創建了一個java項目。另外我在我的電腦上用服務器xmpp openfire創建。 我的服務器的地址爲:192.168.1.4 端口爲:5222smack xmpp庫Java
我的問題是在發送/消息的接收。那是當我嘗試發送消息給另一個用戶時,用戶沒有收到它。現在把我的java程序:
ConnectionConfiguration config;
XMPPConnection con;
config = new ConnectionConfiguration("192.168.1.4", 5222);
con = new XMPPTCPConnection(config);
con.connect();
/*This code is inside the button event log-in*/
con.login(txtUsername.getText(), txtPassword.getText());
/*this code is internal event of sending message to another user*/
ChatManager chatmanager = ChatManager.getInstanceFor(con);
final Chat newChat = chatmanager.createChat(txtDestUsers.getText(), new MessageListener() {
@Override
public void processMessage(Chat chat, Message message) {
txtRicevuti.setText(message.getBody());
}
});
try {
newChat.sendMessage(txtMessage.getText());
}
catch (XMPPException | NotConnectedException e) {
System.out.println("Error Delivering block");
}
txtDestUsers = contains the name of the recipient type [email protected]
txtMessage = message to be sent
txtUsername = myUsername ([email protected])
txtPassword = myPassword
txtRicevuti = received messages
作爲測試我跑了兩次節目,我登錄時使用的兩個帳戶:[email protected]和[email protected]
,如果我嘗試給我自己發消息,消息到達。 就好像txtDestUsers插入另一個用戶的名字一樣,消息沒有到達。
是怎麼回事?