Hi, I’m using Smack 4.1.0 in Android and Openfire 3.10.0 as server. I created a user called admin in the server, and I’m trying to send a message to him, but I don’t know exactly how to do, I’ve tryed many sugestions but none seems to work. I can connect and login to the server with no problems, but the messages aren’t send, I’m logged with the user admin in Spark, and I see the user logged in my application as online, but the messages sent don’t show. I’m doing all that with my pc as server. Here how I’m trying:
XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
config.setUsernameAndPassword(sUser, sSenha);
config.setServiceName(“languagechat”);
config.setHost(“192.168.25.97”);
config.setPort(5222);
AbstractXMPPConnection con = new XMPPTCPConnection(config.build());
try{
\here connects normal
con.connect();
\login works fine too
con.login();
\that’s how I’m trying to send the message
String to = “admin”;
String from = con.getUser();
ChatManager chatManager = ChatManager.getInstanceFor(con);
Message message = new Message(to, Message.Type.chat);
message.setFrom(from);
message.setBody(sMensagem);
message.addExtension(new DefaultExtensionElement(“from”,from));
message.addExtension(new DefaultExtensionElement(“to”, to));
con.sendStanza(message);
} catch (IOException e){
con = null;
return false;
} catch (SmackException e){
con = null;
return false;
} catch (XMPPException e){
con = null;
return false;
}finally {
return true;
}
If someone could help I would appreciate.