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


Java Type.available方法代码示例

本文整理汇总了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;
}
 
开发者ID:snuk182,项目名称:aceim,代码行数:19,代码来源:XMPPEntityAdapter.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: 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);
}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:14,代码来源: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: XmppLoginRunnable

import org.jivesoftware.smack.packet.Presence.Type; //导入方法依赖的package包/类
public XmppLoginRunnable(XmppListener listener) {
	super(listener);
	mType = Type.available;
	mMode = Mode.available;
	mStatus = null;
}
 
开发者ID:ikantech,项目名称:yiim_v2,代码行数:7,代码来源:XmppLoginRunnable.java

示例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;
}
 
开发者ID:tesfaye,项目名称:LOL-Chat,代码行数:9,代码来源:Friend.java


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