Тема: Хтось має досвід зі "smack" ?
Не можу зрозуміти чому TLS з'єднання не працює
public class XMPPclient implements ChatMessageListener
{
private XMPPTCPConnection mConnection;
public XMPPclient(String userName,String pass,String host,int port)
{
XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
//config.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
config.setSocketFactory(SSLSocketFactory.getDefault());
config.setUsernameAndPassword(userName, pass);
try {
config.setXmppDomain(JidCreate.domainBareFrom(host));
} catch (XmppStringprepException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
config.setHostAddress(InetAddress.getByName(host));
} catch (UnknownHostException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
config.setPort(port);
config.setDebuggerEnabled(true);
this.mConnection = new XMPPTCPConnection(config.build());
/*for(;;)
{
if(this.mConnection.isSecureConnection()==true) {break;}
}*/
try
{
mConnection.connect();
mConnection.login();
} catch (SmackException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XMPPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void processMessage(Chat arg0, Message arg1) {
// TODO Auto-generated method stub
if (arg1.getType() == Message.Type.chat)
{
System.out.println(arg1.getBody());
Message answ = new Message(arg1.getFrom(),"");
try
{
arg0.sendMessage(answ);
arg0.close();
}
catch (NotConnectedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}