当前位置: 首页>>代码示例>>Java>>正文


Java Type.unavailable方法代码示例

本文整理汇总了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
	}
}
 
开发者ID:ikantech,项目名称:yiim_v2,代码行数:20,代码来源:XmppVcard.java

示例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;
}
 
开发者ID:snuk182,项目名称:aceim,代码行数:24,代码来源:XMPPCryptoEntityAdapter.java

示例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());
}
 
开发者ID:Pardus-LiderAhenk,项目名称:lider,代码行数:31,代码来源:OnlineRosterListener.java

示例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");
	}
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:12,代码来源:XMPP.java

示例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();
    }
}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:13,代码来源:XMPPServiceImpl.java

示例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");
  }
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:11,代码来源:Xmpp.java

示例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;
}
 
开发者ID:snuk182,项目名称:aceim,代码行数:13,代码来源:XMPPEntityAdapter.java

示例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;
}
 
开发者ID:prive,项目名称:prive-android,代码行数:15,代码来源:XmppConnection.java

示例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;
}
 
开发者ID:ikantech,项目名称:yiim_v2,代码行数:54,代码来源:XmppVcard.java


注:本文中的org.jivesoftware.smack.packet.Presence.Type.unavailable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。