本文整理汇总了Java中org.jivesoftware.smack.packet.Presence.Type.available方法的典型用法代码示例。如果您正苦于以下问题:Java Type.available方法的具体用法?Java Type.available怎么用?Java Type.available使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.packet.Presence.Type
的用法示例。
在下文中一共展示了Type.available方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: xmppPresence2UserStatus
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
public byte xmppPresence2UserStatus(Presence presence) {
if (presence == null || presence.getType() != Type.available){
return -1;
}
if (presence.getMode() == null || presence.getMode() == Mode.available){
return 0;
}
for (byte i=0; i<presenceModes.length; i++) {
Mode m = presenceModes[i];
if (m == presence.getMode()){
return i;
}
}
return -1;
}
示例2: userStatus2XMPPPresence
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
@Override
public Presence userStatus2XMPPPresence(Byte status) {
Presence presence;
if (status < 0 || status >= presenceModes.length) {
presence = new Presence(Type.unavailable);
} else {
presence = new Presence(Type.available);
presence.setMode(presenceModes[status]);
}
if (edProvider != null){
SignedPresence spr = new SignedPresence();
try {
spr.signAndSet(presence.getStatus(), edProvider.getMyKey(), edProvider.getMyKeyPw());
presence.addExtension(spr);
} catch (XMPPException e) {
Logger.log(e);
}
}
return presence;
}
示例3: getInitialOnlineUsers
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的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());
}
示例4: setStatus
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
public void setStatus(boolean available, String status) {
connect();
if (connection != null && connection.isConnected()) {
Presence.Type type = available ? Type.available : Type.unavailable;
Presence presence = new Presence(type);
presence.setStatus(status);
connection.sendPacket(presence);
} else {
log.error("setStatus not connected");
}
}
示例5: sendPresence
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
@Override
public void sendPresence(JID jabberId, PresenceType type, PresenceShow show, String status, JID fromJid)
{
checkNotNull(jabberId);
final Type presenceType = type == null ? Type.available : Type.valueOf(type.name().toLowerCase());
final Mode presenceMode = show == null ? null : Mode.valueOf(show.name().toLowerCase());
org.jivesoftware.smack.packet.Presence presence = new org.jivesoftware.smack.packet.Presence(presenceType, status, 1, presenceMode);
presence.setFrom(fromJid == null ? null : fromJid.getId());
presence.setTo(jabberId.getId());
this.session_.getConnection().sendPacket(presence);
}
示例6: setStatus
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
public void setStatus(boolean available, String status) {
if (connection != null && connection.isConnected()) {
Presence.Type type = available ? Type.available : Type.unavailable;
Presence presence = new Presence(type);
presence.setStatus(status);
// connection.sendPacket(presence);
} else {
log.error("setStatus not connected");
}
}
示例7: userStatus2XMPPPresence
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
public Presence userStatus2XMPPPresence(Byte status) {
Presence presence;
if (status < 0 || status >= presenceModes.length) {
presence = new Presence(Type.unavailable);
} else {
presence = new Presence(Type.available);
presence.setMode(presenceModes[status]);
}
return presence;
}
示例8: XmppLoginRunnable
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
public XmppLoginRunnable(XmppListener listener) {
super(listener);
mType = Type.available;
mMode = Mode.available;
mStatus = null;
}
示例9: isOnline
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
/**
* Returns true if this friend is online.
*
* @return true if online, false if offline
*/
public boolean isOnline() {
return con.getRoster().getPresence(getUserId()).getType() == Type.available;
}