本文整理汇总了Java中org.jivesoftware.smack.packet.Presence.Type.unavailable方法的典型用法代码示例。如果您正苦于以下问题:Java Type.unavailable方法的具体用法?Java Type.unavailable怎么用?Java Type.unavailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.packet.Presence.Type
的用法示例。
在下文中一共展示了Type.unavailable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updatePresence
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
public void updatePresence() {
try {
Connection connection = XmppConnectionUtils.getInstance()
.getConnection();
if (connection != null && connection.isConnected()
&& connection.isAuthenticated()) {
// 在线状态获取
Presence presence = connection.getRoster().getPresence(mUserId);
if (presence.getType() != Type.unavailable) {
setPresence("online");
} else {
setPresence("unavailable");
}
saveToDatabase();
}
} catch (Exception e) {
// TODO: handle exception
}
}
示例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: disconnect
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
@Override
public void disconnect()
{
if (this.isConnected())
{
org.jivesoftware.smack.packet.Presence unavailable = new org.jivesoftware.smack.packet.Presence(Type.unavailable);
unavailable.setFrom(this.session_.getUser().getId().getId());
this.session_.getConnection().disconnect(unavailable);
this.eventManager_.stop();
}
}
示例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: parsePresence
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
protected static int parsePresence(org.jivesoftware.smack.packet.Presence presence) {
int type = Presence.AVAILABLE;
Mode rmode = presence.getMode();
Type rtype = presence.getType();
if (rmode == Mode.away || rmode == Mode.xa)
type = Presence.AWAY;
else if (rmode == Mode.dnd)
type = Presence.DO_NOT_DISTURB;
else if (rtype == Type.unavailable || rtype == Type.error)
type = Presence.OFFLINE;
return type;
}
示例9: loadByVcard
import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
public static XmppVcard loadByVcard(Context context, Connection connection,
String user, XmppVcard xmppVcard) {
XmppVcard ret = null;
if (xmppVcard != null) {
ret = xmppVcard;
} else {
ret = new XmppVcard(context);
}
try {
VCard vCard = new VCard();
vCard.load(connection, user);
Roster roster = connection.getRoster();
ret.setNickName(vCard.getNickName());
// 在线状态获取
Presence presence = roster.getPresence(user);
if (presence.getType() != Type.unavailable) {
ret.setPresence("online");
} else {
ret.setPresence("unavailable");
}
// 加载用户头像
byte[] avatar = vCard.getAvatar();
if (avatar != null) {
YiStoreCache.cacheRawData(user, avatar);
}
ret.setGender(vCard.getField(Const.SEX));
ret.setSign(vCard.getField(Const.SIGN));
ret.setCountry(vCard.getField(Const.COUNTRY));
ret.setProvince(vCard.getField(Const.PROVINCE));
ret.setAddress(vCard.getField(Const.ADDRESS));
ret.setBirthday(Long.valueOf(vCard.getField(Const.BIRTHDAY)));
ret.setSecondBirthday(Long.valueOf(vCard
.getField(Const.SECOND_BIRTHDAY)));
ret.setOnlineTime(Long.valueOf(vCard.getField(Const.ONLINETIME)));
ret.setRealName(vCard.getField(Const.REALNAME));
ret.setBloodGroup(vCard.getField(Const.BLOOD_GROUP));
ret.setPhone(vCard.getField(Const.PHONE));
ret.setOccupation(vCard.getField(Const.OCCUPATION));
ret.setEmail(vCard.getField(Const.EMAIL));
//通知重新加载好友列表
Intent intent = new Intent(Const.NOTIFY_RELOAD_ROSTER_ENTRIES);
context.sendBroadcast(intent);
} catch (Exception e) {
}
return ret;
}