xmpp openfire 使用 ssl 了吗
答案:2 悬赏:60 手机版
解决时间 2021-01-03 11:32
- 提问者网友:温柔港
- 2021-01-02 20:05
xmpp openfire 使用 ssl 了吗
最佳答案
- 五星知识达人网友:鱼芗
- 2021-01-02 20:50
给你个例子连接类importorg.jivesoftware.smack.ConnectionConfiguration;importorg.jivesoftware.smack.XMPPConnection;importorg.jivesoftware.smack.XMPPException;publicclassConn{privatestaticXMPPConnectionconnection=null;publicstaticXMPPConnectiongetConnection(Stringdomain)throwsXMPPException{XMPPConnectionconnection=newXMPPConnection(domain);connection.connect();returnconnection;}publicstaticXMPPConnectiongetConnection(Stringdomain,intport)throwsXMPPException{if(connection==null){ConnectionConfigurationconfig=newConnectionConfiguration(domain,port);connection=newXMPPConnection(config);connection.connect();}returnconnection;}}测试类importorg.jivesoftware.smack.Chat;importorg.jivesoftware.smack.ChatManager;importorg.jivesoftware.smack.ChatManagerListener;importorg.jivesoftware.smack.MessageListener;importorg.jivesoftware.smack.Roster;importorg.jivesoftware.smack.RosterEntry;importorg.jivesoftware.smack.RosterGroup;importorg.jivesoftware.smack.RosterListener;importorg.jivesoftware.smack.XMPPConnection;importorg.jivesoftware.smack.XMPPException;importorg.jivesoftware.smack.packet.Message;importorg.jivesoftware.smack.packet.Presence;publicclassTest2{publicstaticbooleanLongAccount(XMPPConnectionconnection,Stringusername,Stringpassword){try{connection.login(username,password);returntrue;}catch(Exceptione){e.printStackTrace();returnfalse;}}publicstaticvoidmain(String[]args)throwsXMPPException{XMPPConnectionconnection=Conn.getConnection("192.168.1.117");booleant=LongAccount(connection,"qeekey@localhost.localdomain","password");System.out.println("tlogin="+t);if(t){ChatManagerchatmanager=connection.getChatManager();//新建一个会话ChatnewChat=chatmanager.createChat("lxm@localhost.localdomain",newMessageListener(){publicvoidprocessMessage(Chatchat,Messagemessage){System.out.println("startme,Receivedfrom【"+message.getFrom()+"】message:"+message.getBody());}});//发送消息newChat.sendMessage("我是菜鸟");}}转载,仅供参考。
全部回答
- 1楼网友:酒醒三更
- 2021-01-02 21:09
providermanager去注册一下。iqprovider和extensionprovider
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
正方形一边上任一点到这个正方形两条对角线的 |
阴历怎么看 ? |