本文整理汇总了Java中org.jivesoftware.smack.roster.Roster.reloadAndWait方法的典型用法代码示例。如果您正苦于以下问题:Java Roster.reloadAndWait方法的具体用法?Java Roster.reloadAndWait怎么用?Java Roster.reloadAndWait使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.roster.Roster
的用法示例。
在下文中一共展示了Roster.reloadAndWait方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeContact
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void removeContact(String jidString)
throws SmackException.NotLoggedInException, InterruptedException,
SmackException.NotConnectedException, XMPPException.XMPPErrorException,
SmackException.NoResponseException, XmppStringprepException {
Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
if (!roster.isLoaded()) {
roster.reloadAndWait();
}
BareJid jid = JidCreate.bareFrom(jidString);
roster.removeEntry(roster.getEntry(jid));
Presence presence = new Presence(Presence.Type.unsubscribe);
presence.setTo(JidCreate.from(jidString));
XMPPSession.getInstance().sendStanza(presence);
}
示例2: addContact
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void addContact(String jidString)
throws SmackException.NotLoggedInException, InterruptedException,
SmackException.NotConnectedException, XMPPException.XMPPErrorException,
SmackException.NoResponseException, XmppStringprepException {
Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
if (!roster.isLoaded()) {
roster.reloadAndWait();
}
BareJid jid = JidCreate.bareFrom(jidString);
String name = XMPPUtils.fromJIDToUserName(jidString);
String[] groups = new String[]{"Buddies"};
roster.createEntry(jid, name, groups);
roster.sendSubscriptionRequest(jid);
}
示例3: listRoster
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
/**
* creates a list of all RosterEntries
* @return the rosterEntryArray
*/
public RosterEntry[] listRoster(){
try{
// get the roster and if it is not loaded reload it
Roster roster = Roster.getInstanceFor(connection);
if (!roster.isLoaded())
roster.reloadAndWait();
RosterEntry[] result = new RosterEntry[roster.getEntries().size()];
int i = 0;
// loop through all roster entries and append them to the array
for (RosterEntry entry: roster.getEntries()){
result[i++] = entry;
}
return result;
}catch (Exception e){
e.printStackTrace();
}
return new RosterEntry[0];
}
示例4: run
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
@Override
public void run(){
Roster roster = xmppManager.getRoster();
if (roster != null && !roster.isLoaded())
try{
roster.reloadAndWait();
Log.d("SERVICE_DEBUG", "reloaded roster");
}catch (Exception e){
Log.e("SERVICE_ERROR", "Couldn't load the roster");
e.printStackTrace();
}
if (roster != null){
Collection<RosterEntry> entries = roster.getEntries();
for (RosterEntry entry : entries)
presenceReceived(roster.getPresence(entry.getUser()));
roster.addRosterListener(rosterListener);
}
}
示例5: removeAllContacts
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void removeAllContacts()
throws SmackException.NotLoggedInException, InterruptedException,
SmackException.NotConnectedException, XMPPException.XMPPErrorException,
SmackException.NoResponseException {
Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
if (!roster.isLoaded()) {
roster.reloadAndWait();
}
for (RosterEntry entry : roster.getEntries()) {
roster.removeEntry(entry);
Presence presence = new Presence(Presence.Type.unsubscribe);
presence.setTo(entry.getJid());
XMPPSession.getInstance().sendStanza(presence);
}
}
示例6: getContacts
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public HashMap<Jid, Presence.Type> getContacts()
throws SmackException.NotLoggedInException, InterruptedException,
SmackException.NotConnectedException {
Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
if (!roster.isLoaded()) {
roster.reloadAndWait();
}
String groupName = "Buddies";
RosterGroup group = roster.getGroup(groupName);
if (group == null) {
roster.createGroup(groupName);
group = roster.getGroup(groupName);
}
HashMap<Jid, Presence.Type> buddies = new HashMap<>();
List<RosterEntry> entries = group.getEntries();
for (RosterEntry entry : entries) {
BareJid jid = entry.getJid();
Presence.Type status = roster.getPresence(jid).getType();
buddies.put(jid, status);
}
return buddies;
}
示例7: getContactsWithSubscriptionPending
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public HashMap<Jid, Presence.Type> getContactsWithSubscriptionPending()
throws SmackException.NotLoggedInException, InterruptedException,
SmackException.NotConnectedException {
Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
if (!roster.isLoaded()) {
roster.reloadAndWait();
}
String groupName = "Buddies";
RosterGroup group = roster.getGroup(groupName);
if (group == null) {
roster.createGroup(groupName);
group = roster.getGroup(groupName);
}
HashMap<Jid, Presence.Type> buddiesPending = new HashMap<>();
List<RosterEntry> entries = group.getEntries();
for (RosterEntry entry : entries) {
if (entry.isSubscriptionPending()) {
BareJid jid = entry.getJid();
Presence.Type status = roster.getPresence(jid).getType();
buddiesPending.put(jid, status);
}
}
return buddiesPending;
}