I created a java project using the library smack. Also I created on my computer with a server xmpp openfire. the address of my server is: 192.168.1.4 the port is: 5222
my problem is sending / reception of the messages. That is when I try to send a message to another user, the user does not receive it. now place my java program:
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
as a test I ran the program twice, and I logged in with the two accounts: [email protected] and [email protected]
if I try to send a message to myself, the message arrives. As if txtDestUsers insert the name of another user, the message does not arrive.
How so?