本文整理汇总了Java中org.jivesoftware.smack.Roster.addRosterListener方法的典型用法代码示例。如果您正苦于以下问题:Java Roster.addRosterListener方法的具体用法?Java Roster.addRosterListener怎么用?Java Roster.addRosterListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.Roster
的用法示例。
在下文中一共展示了Roster.addRosterListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RosterAdapter
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* Constructor.
* @param roster The roster to adapt.
* @param context The context of the RosterAdapter.
* @param avatarMgr The AvatarManager of the connection
*/
public RosterAdapter(final Roster roster, final Context context, final AvatarManager avatarMgr) {
mAdaptee = roster;
roster.addRosterListener(mRosterListener);
mDefaultStatusMessages = createDefaultStatusMessagesMap(context);
mAvatarManager = avatarMgr;
if (mAvatarManager != null)
mAvatarManager.addAvatarListener(new AvatarEventListener());
}
示例2: checkforUserAvailability
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* Checking whether the user is available in the contact list.
*
* @param roster
* @param userXmppId
* @return
*/
public boolean checkforUserAvailability(Roster roster, String userXmppId) {
boolean isAvailable = false;
XmppSubscriptionListener listener = new XmppSubscriptionListener(userXmppId);
roster.addRosterListener(listener);
Presence presence = roster.getPresence(userXmppId);
boolean status = isAvailable(roster, userXmppId);
try {
if (!status) {
if (log.isInfoEnabled()) {
log.info("The User is not subscribed.");
}
boolean contactAddStatus = new XmppSubscriber().addContact(roster, userXmppId);
if (contactAddStatus) {
if (log.isInfoEnabled()) {
log.info("User's Contact is added successfully..");
}
} else {
if (log.isInfoEnabled()) {
log.info("Failed to add contact.");
}
}
if (!presence.isAvailable()) {
while (!listener.isOnline()) {
Thread.sleep(5000);
}
}
isAvailable = true;
} else {
if (log.isInfoEnabled()) {
log.info("User is not online..");
}
while (!listener.isOnline()) {
Thread.sleep(5000);
}
isAvailable = true;
}
} catch (InterruptedException e) {
log.error("Error while checking user availability", e);
} finally {
roster.removeRosterListener(listener);
}
return isAvailable;
}
示例3: listenToRoster
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
public void listenToRoster(final Roster roster) {
roster.addRosterListener(rListener);
}