国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
Xmpp協(xié)議 OpenFire服務(wù)器 Asmack Android客戶(hù)端 一些Bug的解決方法

Openfire做為服務(wù)器,Asmack 作為Android端的實(shí)現(xiàn)。

1.只能發(fā) 不能收

如果按照API上寫(xiě)的去做,直接在new 與某個(gè)用戶(hù)的Chat 之后 addListener,結(jié)果就是只能發(fā)不能收。

按照下面這樣寫(xiě),可以解決。

  1. ChatManager cm=conn.getChatManager();  
  2.             Chat newChat = cm.createChat(  
  3.                     "hanchenxi@workgroup"null);  
  4.             cm.addChatListener(new ChatManagerListener() {  
  5.                   
  6.                 @Override  
  7.                 public void chatCreated(Chat arg0, boolean arg1) {  
  8.                     arg0.addMessageListener(new MessageListener() {  
  9.                           
  10.                         @Override  
  11.                         public void processMessage(Chat arg0, Message arg1) {  
  12.                             if (arg1.getFrom().contains("")) {  
  13.                                   
  14.                             }  
  15.                             Log.i("收到消息", arg1.getBody());  
  16.                               
  17.                               
  18.                         }  
  19.                     });  
  20.                       
  21.                 }  
  22.             });  

2.找不到密鑰憑證

在連接配置中加入。

  1. ConnectionConfiguration connConfig = new ConnectionConfiguration("192.168.1.116"5222);  
  2.             connConfig.setTruststorePath("/system/etc/security/cacerts.bks");  
  3.             connConfig.setTruststoreType("bks");  
  4.             con = new XMPPConnection(connConfig);  
  5.             con.connect();  

一種支持4.0以上系統(tǒng)的寫(xiě)法

  1. try {  
  2.             ConnectionConfiguration connConfig = new ConnectionConfiguration(  
  3.                     Config.getString("XmppTools.ServerAddress"), 5222); //$NON-NLS-1$  
  4.             Log.i("當(dāng)前操作系統(tǒng)版本API Level=", Build.VERSION.SDK_INT + ""); //$NON-NLS-1$ //$NON-NLS-2$  
  5.             if (Build.VERSION.SDK_INT >= 14) {  
  6.                 connConfig.setTruststoreType("AndroidCAStore"); //$NON-NLS-1$  
  7.                 connConfig.setTruststorePassword(null);  
  8.                 connConfig.setTruststorePath(null);  
  9.             } else {  
  10.                 connConfig.setTruststoreType("BKS"); //$NON-NLS-1$  
  11.                 String path = System.getProperty("javax.net.ssl.trustStore"); //$NON-NLS-1$  
  12.                 if (path == null)  
  13.                     path = System.getProperty("java.home") + File.separator //$NON-NLS-1$  
  14.                             + "etc" + File.separator + "security" //$NON-NLS-1$ //$NON-NLS-2$  
  15.                             + File.separator + "cacerts.bks"//$NON-NLS-1$  
  16.                 connConfig.setTruststorePath(path);  
  17.             }  
  18.             // connConfig.setSASLAuthenticationEnabled(false);  
  19.             connConfig.setReconnectionAllowed(true);  
  20.             connConfig.setSecurityMode(SecurityMode.disabled);  
  21.             con = new XMPPConnection(connConfig);  
  22.             con.connect();  

3.網(wǎng)絡(luò)方面的異常

保證網(wǎng)絡(luò)連接的前提下,在連接前

  1. {  
  2.             java.lang.System.setProperty("java.net.preferIPv4Stack""true");  
  3.             java.lang.System.setProperty("java.net.preferIPv6Addresses",  
  4.                     "false");  
  5.         }  

4.文件傳輸

修改asmack源碼包 org.jivesoftware.smackx.filetransfer.Socks5TransferNegotiator.discoverLocalIP()方法

  1. private String discoverLocalIP() throws UnknownHostException {    
  2.         try {    
  3.             for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {    
  4.                 NetworkInterface intf = en.nextElement();    
  5.                 for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {    
  6.                     InetAddress inetAddress = enumIpAddr.nextElement();    
  7.                     if (!inetAddress.isLoopbackAddress()) {    
  8.                         return inetAddress.getHostAddress().toString();    
  9.                     }    
  10.                 }    
  11.             }    
  12.         } catch (SocketException ex) {    
  13.             Logger.error("Error retrieving the local IP", ex);    
  14.         }    
  15.         throw new UnknownHostException("Failed to retrieve local IP");    
  16.         //return InetAddress.getLocalHost().getHostAddress();     
  17.     }    

暫時(shí)就這么多了。往后發(fā)現(xiàn)繼續(xù)更新。一直到這個(gè)項(xiàng)目完畢。

修改后的asmack.jar 可以在我的資源里面下載

http://download.csdn.net/detail/yaeio/4525142


本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Openfire asmack spark開(kāi)發(fā)桌面與android平臺(tái)的即時(shí)通訊軟件
Android基于XMPP Smack Openfire下學(xué)習(xí)開(kāi)發(fā)IM(一)實(shí)現(xiàn)用戶(hù)注冊(cè)、登錄、修改密碼和注銷(xiāo)等
android基于xmpp的即時(shí)通訊應(yīng)用
nl80211 和 wext
Android中UI設(shè)計(jì)的一些技巧!!!
Android源碼中屏幕截圖的實(shí)現(xiàn)
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服