smack4.2 用戶登錄代碼

  
        public static AbstractXMPPConnection getConnection(String domain,int port,String resource) throws XMPPException, SmackException, IOException, InterruptedException {  
         
             XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
             .setXmppDomain(JidCreate.domainBareFrom(domain))
             .setHost(domain)  
             .setPort(port)
             .setCompressionEnabled(false)
             .setSecurityMode(SecurityMode.disabled)
             .setResource(resource)
             .build();  //得到基於xmpp協議的連接對象  
             AbstractXMPPConnection connection =new XMPPTCPConnection(config); 
             
             connection.connect();
             return connection;  

        }


conn.login("test", "test");

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章