当前位置: 首页 > 工具软件 > SMACK > 使用案例 >

smack登陆

南宫星波
2023-12-01
package test;

import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;

public class Smacks {

	/**
	 * @param args
	 */ 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ConnectionConfiguration config = new ConnectionConfiguration("b02", 5222);
		XMPPConnection connection = new XMPPConnection(config);
		try {
			connection.connect();
			connection.login("admin", "adminss");
			if(connection.isAuthenticated()){
				System.out.println("登陆成功!");
			}
			else{
				System.out.println("登陆失败!");
			}
		} catch (XMPPException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		
	}
	
}

 类似资料: