當前位置: 首頁>>代碼示例>>Java>>正文


Java Presence.Type方法代碼示例

本文整理匯總了Java中org.jivesoftware.smack.packet.Presence.Type方法的典型用法代碼示例。如果您正苦於以下問題:Java Presence.Type方法的具體用法?Java Presence.Type怎麽用?Java Presence.Type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jivesoftware.smack.packet.Presence的用法示例。


在下文中一共展示了Presence.Type方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: perform

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
    Presence.Type typeVal = Presence.Type.valueOf(sampler.getPropertyAsString(TYPE, Presence.Type.available.toString()));
    Presence.Mode modeVal = Presence.Mode.valueOf(sampler.getPropertyAsString(MODE, Presence.Mode.available.toString()));

    Presence presence = new Presence(typeVal);
    presence.setMode(modeVal);

    String to = sampler.getPropertyAsString(RECIPIENT);
    if (!to.isEmpty()) {
        presence.setTo(to);
    }

    String text = sampler.getPropertyAsString(STATUS_TEXT);
    if (!text.isEmpty()) {
        presence.setStatus(text);
    }

    sampler.getXMPPConnection().sendPacket(presence);
    res.setSamplerData(presence.toXML().toString());
    return res;
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:23,代碼來源:SendPresence.java

示例2: getStatusFromContact

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
public Presence.Type getStatusFromContact(String name) {
    try {
        HashMap<Jid, Presence.Type> buddies = getContacts();

        for (Map.Entry<Jid, Presence.Type> pair : buddies.entrySet()) {
            if (XMPPUtils.fromJIDToUserName(pair.getKey().toString()).equals(name)) {
                return pair.getValue();
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    return Presence.Type.unavailable;
}
 
開發者ID:esl,項目名稱:mangosta-android,代碼行數:17,代碼來源:RosterManager.java

示例3: onPresenceUpdate

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
public void onPresenceUpdate(JID jid, Presence.Type type, Optional<String> optStatus) {
    JID myJID = mClient.getOwnJID().orElse(null);
    if (myJID != null && myJID.equals(jid))
        // don't wanna see myself
        return;

    Contact contact = mModel.contacts().get(jid).orElse(null);
    if (contact == null) {
        LOGGER.info("can't find contact with jid: "+jid);
        return;
    }

    if (type == Presence.Type.available) {
        contact.setOnlineStatus(Contact.Online.YES);
    } else if (type == Presence.Type.unavailable) {
        contact.setOnlineStatus(Contact.Online.NO);
    }

    if (optStatus.isPresent())
        contact.setStatusText(optStatus.get());
}
 
開發者ID:kontalk,項目名稱:desktopclient-java,代碼行數:22,代碼來源:RosterHandler.java

示例4: setPresence

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * 設置用戶狀態
 * @param xmppConnection
 * @param type 狀態
 * @param status 狀態描述
 * @return
 */
public  static boolean  setPresence(XMPPConnection xmppConnection,Presence.Type type,String status){
    Presence presence=new Presence(type);
    presence.setStatus(status);
    try{
        xmppConnection.sendPacket(presence);
        return true;
    }catch (Exception e){
        return  false;
    }
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:18,代碼來源:XMPPUtil.java

示例5: setPresence

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * 設置用戶狀態
 * @param xmppConnection
 * @param type
 * @param status
 * @return
 */
public static boolean setPresence(XMPPConnection xmppConnection, Presence.Type type, String status) {
    Presence presence = new Presence(type);
    presence.setStatus(status);
    try {
        xmppConnection.sendPacket(presence);
        return true;
    } catch (Exception e) {
        Log.e("setPresence", e.getMessage());
        return false;
    }
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:19,代碼來源:XMPPUtil.java

示例6: isChatWithContact

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
private boolean isChatWithContact() {
    try {
        HashMap<Jid, Presence.Type> buddies = RosterManager.getInstance().getContacts();
        for (Map.Entry pair : buddies.entrySet()) {
            if (mChat.getJid().equals(pair.getKey().toString())) {
                return true;
            }
        }
    } catch (SmackException.NotLoggedInException | InterruptedException | SmackException.NotConnectedException e) {
        e.printStackTrace();
    }
    return false;
}
 
開發者ID:esl,項目名稱:mangosta-android,代碼行數:14,代碼來源:ChatActivity.java

示例7: loadRosterContactsChats

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
public void loadRosterContactsChats() throws SmackException.NotLoggedInException, InterruptedException, SmackException.NotConnectedException {
    try {
        HashMap<Jid, Presence.Type> buddies = RosterManager.getInstance().getContacts();
        for (Map.Entry pair : buddies.entrySet()) {
            String userJid = pair.getKey().toString();
            RoomsListManager.getInstance().createChatIfNotExists(userJid, true);
        }
    } finally {
        mListener.onRoomsLoaded();
    }
}
 
開發者ID:esl,項目名稱:mangosta-android,代碼行數:12,代碼來源:RoomManager.java

示例8: getContacts

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
public HashMap<Jid, Presence.Type> getContacts()
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException {
    Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
    }

    String groupName = "Buddies";

    RosterGroup group = roster.getGroup(groupName);

    if (group == null) {
        roster.createGroup(groupName);
        group = roster.getGroup(groupName);
    }

    HashMap<Jid, Presence.Type> buddies = new HashMap<>();

    List<RosterEntry> entries = group.getEntries();
    for (RosterEntry entry : entries) {
        BareJid jid = entry.getJid();
        Presence.Type status = roster.getPresence(jid).getType();
        buddies.put(jid, status);
    }

    return buddies;
}
 
開發者ID:esl,項目名稱:mangosta-android,代碼行數:29,代碼來源:RosterManager.java

示例9: getContactsWithSubscriptionPending

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
public HashMap<Jid, Presence.Type> getContactsWithSubscriptionPending()
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException {
    Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
    }

    String groupName = "Buddies";

    RosterGroup group = roster.getGroup(groupName);

    if (group == null) {
        roster.createGroup(groupName);
        group = roster.getGroup(groupName);
    }

    HashMap<Jid, Presence.Type> buddiesPending = new HashMap<>();

    List<RosterEntry> entries = group.getEntries();
    for (RosterEntry entry : entries) {
        if (entry.isSubscriptionPending()) {
            BareJid jid = entry.getJid();
            Presence.Type status = roster.getPresence(jid).getType();
            buddiesPending.put(jid, status);
        }
    }

    return buddiesPending;
}
 
開發者ID:esl,項目名稱:mangosta-android,代碼行數:31,代碼來源:RosterManager.java

示例10: hasContactSubscriptionPending

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
public boolean hasContactSubscriptionPending(Jid jid)
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException {
    HashMap<Jid, Presence.Type> buddies = getContactsWithSubscriptionPending();
    return buddies.containsKey(jid);

}
 
開發者ID:esl,項目名稱:mangosta-android,代碼行數:8,代碼來源:RosterManager.java

示例11: setStatus

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的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

示例12: sendSubscribe

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * �ظ�һ��presence��Ϣ���û������û��ǽ��ջ��Ǿܾ�
 *
 * @param type
 * @param to
 */
protected void sendSubscribe(Presence.Type type, String to)
{
    Presence presence = new Presence(type);
    presence.setTo(to);
    XmppConnectionManager.getInstance().getConnection().sendPacket(presence);
}
 
開發者ID:ice-coffee,項目名稱:EIM,代碼行數:13,代碼來源:MyNoticeActivity.java

示例13: sendSubscribe

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * �ظ�һ��presence��Ϣ���û�
 * 
 * @param type
 * @param to
 */
protected void sendSubscribe(Presence.Type type, String to) {
	Presence presence = new Presence(type);
	presence.setTo(to);
	XmppConnectionManager.getInstance().getConnection()
			.sendPacket(presence);
}
 
開發者ID:ice-coffee,項目名稱:EIM,代碼行數:13,代碼來源:AContacterActivity.java

示例14: sendPresenceEvent

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * helper method to trigger a presence update even if the server does not send a presence packet itself (e.g. entering a test but no other buddies are online)
 * 
 * @param username
 */
@Override
public void sendPresenceEvent(final Presence.Type type, final String username) {
    final Presence presence = new Presence(type);
    presence.setTo(username);
    final GenericEventListener listener = listeners.get(username);
    if (listener != null) {
        listener.event(new InstantMessagingEvent(presence, "presence"));
    }
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:15,代碼來源:ClientManagerImpl.java

示例15: setStatus

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的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


注:本文中的org.jivesoftware.smack.packet.Presence.Type方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。