本文整理汇总了Java中org.jivesoftware.smack.roster.Roster.getEntries方法的典型用法代码示例。如果您正苦于以下问题:Java Roster.getEntries方法的具体用法?Java Roster.getEntries怎么用?Java Roster.getEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.roster.Roster
的用法示例。
在下文中一共展示了Roster.getEntries方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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];
}
示例2: 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);
}
}
示例3: rebuildRoster
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
private void rebuildRoster() {
Roster roster = Roster.getInstanceFor(mConnection);
if (roster == null) {
Logger.info(TAG, "no roster, skipping rebuild roster");
return;
}
Set<RosterEntry> entries = roster.getEntries();
ArrayList<XmppRosterEntry> newRoster = new ArrayList<>(entries.size());
for (RosterEntry entry : entries) {
XmppRosterEntry newEntry = getRosterEntryFor(roster, entry);
newRoster.add(newEntry);
}
Collections.sort(newRoster);
XmppService.setRosterEntries(newRoster);
XmppServiceBroadcastEventEmitter.broadcastRosterChanged();
}
示例4: 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);
}
}
示例5: entriesAdded
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
@Override
public void entriesAdded(Collection<String> collection){
Roster roster = xmppManager.getRoster();
Collection<RosterEntry> entries = roster.getEntries();
for (RosterEntry entry : entries)
presenceReceived(roster.getPresence(entry.getUser()));
}
示例6: entriesUpdated
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
@Override
public void entriesUpdated(Collection<String> collection){
Roster roster = xmppManager.getRoster();
Collection<RosterEntry> entries = roster.getEntries();
for (RosterEntry entry : entries)
presenceReceived(roster.getPresence(entry.getUser()));
}
示例7: getInitialOnlineUsers
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
/**
* Get online users from roster and store in onlineUsers
*/
private void getInitialOnlineUsers() {
Roster roster = Roster.getInstanceFor(connection);
Collection<RosterEntry> entries = roster.getEntries();
if (entries != null && !entries.isEmpty()) {
for (RosterEntry entry : entries) {
String jid = entry.getUser();
Presence presence = roster.getPresence(jid);
if (presence != null) {
XMPPError xmppError = presence.getError();
if (xmppError != null) {
logger.error(xmppError.getDescriptiveText());
} else {
try {
if (presence.getType() == Type.available) {
onlineUsers.add(jid.substring(0, jid.indexOf('@')));
} else if (presence.getType() == Type.unavailable) {
onlineUsers.remove(jid.substring(0, jid.indexOf('@')));
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
}
}
logger.debug("Online users: {}", onlineUsers.toString());
}
示例8: RosterExchange
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
/**
* Creates a new roster exchange package with the entries specified in roster.
*
* @param roster the roster to send to other XMPP entity.
*/
public RosterExchange(Roster roster) {
// Add all the roster entries to the new RosterExchange
for (RosterEntry rosterEntry : roster.getEntries()) {
this.addRosterEntry(rosterEntry);
}
}
示例9: onRosterLoaded
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
@Override
public void onRosterLoaded(Roster roster) {
Set<RosterEntry> entries = roster.getEntries();
LOGGER.info("loading "+entries.size()+" entries");
mHandler.onLoaded(entries.stream()
.map(KonRosterListener::clientToModel)
.collect(Collectors.toList()));
mLoaded = true;
}
示例10: handlePresence
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
@CommandHandler(name = ACTION_PRESENCE)
private boolean handlePresence(Intent intent, boolean canConnect) {
if (canConnect && isConnected()) {
final String id = intent.getStringExtra(EXTRA_PACKET_ID);
String type = intent.getStringExtra(EXTRA_TYPE);
final String to = intent.getStringExtra(EXTRA_TO);
if ("probe".equals(type)) {
// probing is actually looking into the roster
final Roster roster = getRoster();
if (to == null) {
for (RosterEntry entry : roster.getEntries()) {
broadcastPresence(roster, entry, id);
}
// broadcast our own presence
broadcastMyPresence(id);
}
else {
queueTask(new Runnable() {
@Override
public void run() {
try {
broadcastPresence(roster, JidCreate.bareFrom(to), id);
}
catch (XmppStringprepException e) {
Log.w(TAG, "error parsing JID: " + e.getCausingString(), e);
// report it because it's a big deal
ReportingManager.logException(e);
throw new IllegalArgumentException(e);
}
}
});
}
}
else {
// FIXME isn't this somewhat the same as createPresence?
String show = intent.getStringExtra(EXTRA_SHOW);
Presence p = new Presence(type != null ? Presence.Type.valueOf(type) : Presence.Type.available);
p.setStanzaId(id);
if (to != null)
p.setTo(to);
if (intent.hasExtra(EXTRA_PRIORITY))
p.setPriority(intent.getIntExtra(EXTRA_PRIORITY, 0));
String status = intent.getStringExtra(EXTRA_STATUS);
if (!TextUtils.isEmpty(status))
p.setStatus(status);
if (show != null)
p.setMode(Presence.Mode.valueOf(show));
sendPacket(p);
}
}
return false;
}