基于Openfire消息服务器应用Smack发送即时消息源码示例(二)
ry : rosters) {
System.out.print("name: " + rosterEntry.getName() + ",jid: "
+ rosterEntry.getUser()); // 此处可获取用户JID
System.out.println("");
}
return null;
}
/**
* 获取用户列表(含组信息)
*
* @param username
* @param pass
* @return
* @throws XMPPException
*/
public List getRoster(String username, String pass)
throws XMPPException {
Connection con = IMServer.getConnection();
con.connect();
con.login(username, pass);
roster = con.getRoster();
List EntriesList = new ArrayList();
Collection rosterEntry = roster.getEntries();
Iterator i = rosterEntry.iterator();
while (i.hasNext()) {
EntriesList.add(i.next());
}
return EntriesList;
}
}