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


Java Presence.setStatus方法代碼示例

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


在下文中一共展示了Presence.setStatus方法的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: sendStatus

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
protected void sendStatus(JabberPlayer player, String recipient, JabberRoom room) {
  final SimpleStatus s = (SimpleStatus) player.getStatus();
  final Presence p = new Presence(Presence.Type.available);
  p.setStatus(""); //$NON-NLS-1$
  p.setMode(Presence.Mode.chat);
  p.setProperty(SimpleStatus.LOOKING, s.isLooking());
  p.setProperty(SimpleStatus.AWAY, s.isAway());
  p.setProperty(SimpleStatus.IP, s.getIp());
  p.setProperty(SimpleStatus.CLIENT, s.getClient());
  p.setProperty(SimpleStatus.MODULE_VERSION, s.getModuleVersion());
  p.setProperty(SimpleStatus.CRC, s.getCrc());
  p.setProperty(REAL_NAME, player.getName()); //$NON-NLS-1$
  if (room != null) {
    p.setProperty(ROOM_CONFIG, room.encodeConfig());
    p.setProperty(ROOM_JID, room.getJID());
    p.setProperty(ROOM_NAME, room.getName());
  }
  p.setTo(recipient == null ? monitorRoom.getRoom() : recipient);
  conn.sendPacket(p);
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:21,代碼來源:JabberClient.java

示例3: setStatus

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * sets the status
 *
 * @param available if true the status type will be set to available otherwise to unavailable
 * @param status    the status message
 * @return true if setting the status was successful
 */
public boolean setStatus(boolean available, String status){
  if (connection != null && connection.isConnected()){
    // set the presence type
    Presence presence = new Presence(available
            ? Presence.Type.available
            : Presence.Type.unavailable);

    presence.setStatus(status);
    try{
      connection.sendStanza(presence);
      Log.d("DEBUG", "Success: Set status.");
      return true;
    }catch (Exception e){
      System.err.println(e.toString());
      Log.e("ERROR", "Error while setting status.");
      return false;
    }
  }
  Log.e("ERROR", "Setting status failed: No connection.");
  return false;
}
 
開發者ID:Nik-Sch,項目名稱:ChatApp-Android,代碼行數:29,代碼來源:XmppManager.java

示例4: setStatus

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * Sets the agent's current status with the workgroup. The presence mode affects how offers
 * are routed to the agent. The possible presence modes with their meanings are as follows:<ul>
 * <p/>
 * <li>Presence.Mode.AVAILABLE -- (Default) the agent is available for more chats
 * (equivalent to Presence.Mode.CHAT).
 * <li>Presence.Mode.DO_NOT_DISTURB -- the agent is busy and should not be disturbed.
 * However, special case, or extreme urgency chats may still be offered to the agent.
 * <li>Presence.Mode.AWAY -- the agent is not available and should not
 * have a chat routed to them (equivalent to Presence.Mode.EXTENDED_AWAY).</ul>
 *
 * @param presenceMode the presence mode of the agent.
 * @param status       sets the status message of the presence update.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 * @throws IllegalStateException if the agent is not online with the workgroup.
 */
public void setStatus(Presence.Mode presenceMode, String status) throws NoResponseException, XMPPErrorException, NotConnectedException {
    if (!online) {
        throw new IllegalStateException("Cannot set status when the agent is not online.");
    }

    if (presenceMode == null) {
        presenceMode = Presence.Mode.available;
    }
    this.presenceMode = presenceMode;

    Presence presence = new Presence(Presence.Type.available);
    presence.setMode(presenceMode);
    presence.setTo(this.getWorkgroupJID());

    if (status != null) {
        presence.setStatus(status);
    }
    presence.addExtension(new MetaData(this.metaData));

    PacketCollector collector = this.connection.createPacketCollectorAndSend(new AndFilter(new StanzaTypeFilter(Presence.class),
            FromMatchesFilter.create(workgroupJID)), presence);

    collector.nextResultOrThrow();
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:43,代碼來源:AgentSession.java

示例5: changeAvailabilityStatus

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * Changes the occupant's availability status within the room. The presence type
 * will remain available but with a new status that describes the presence update and
 * a new presence mode (e.g. Extended away).
 *
 * @param status a text message describing the presence update.
 * @param mode the mode type for the presence update.
 * @throws NotConnectedException 
 */
public void changeAvailabilityStatus(String status, Presence.Mode mode) throws NotConnectedException {
    StringUtils.requireNotNullOrEmpty(nickname, "Nickname must not be null or blank.");
    // Check that we already have joined the room before attempting to change the
    // availability status.
    if (!joined) {
        throw new IllegalStateException(
            "Must be logged into the room to change the " + "availability status.");
    }
    // We change the availability status by sending a presence packet to the room with the
    // new presence status and mode
    Presence joinPresence = new Presence(Presence.Type.available);
    joinPresence.setStatus(status);
    joinPresence.setMode(mode);
    joinPresence.setTo(room + "/" + nickname);

    // Send join packet.
    connection.sendStanza(joinPresence);
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:28,代碼來源:MultiUserChat.java

示例6: changeAvailabilityStatus

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * Changes the occupant's availability status within the room. The presence type
 * will remain available but with a new status that describes the presence update and
 * a new presence mode (e.g. Extended away).
 *
 * @param status a text message describing the presence update.
 * @param mode the mode type for the presence update.
 */
public void changeAvailabilityStatus(String status, Presence.Mode mode) {
    if (nickname == null || nickname.equals("")) {
        throw new IllegalArgumentException("Nickname must not be null or blank.");
    }
    // Check that we already have joined the room before attempting to change the
    // availability status.
    if (!joined) {
        throw new IllegalStateException(
            "Must be logged into the room to change the " + "availability status.");
    }
    // We change the availability status by sending a presence packet to the room with the
    // new presence status and mode
    Presence joinPresence = new Presence(Presence.Type.available);
    joinPresence.setStatus(status);
    joinPresence.setMode(mode);
    joinPresence.setTo(room + "/" + nickname);
    // Invoke presence interceptors so that extra information can be dynamically added
    for (PacketInterceptor packetInterceptor : presenceInterceptors) {
        packetInterceptor.interceptPacket(joinPresence);
    }

    // Send join packet.
    connection.sendPacket(joinPresence);
}
 
開發者ID:ice-coffee,項目名稱:EIM,代碼行數:33,代碼來源:MultiUserChat.java

示例7: setStatusFromConfig

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
@Override
public void setStatusFromConfig() {// 設置自己的當前狀態,供外部服務調用
	boolean messageCarbons = PreferenceUtils.getPrefBoolean(mService,
			PreferenceConstants.MESSAGE_CARBONS, true);
	String statusMode = PreferenceUtils.getPrefString(mService,
			PreferenceConstants.STATUS_MODE, PreferenceConstants.AVAILABLE);
	String statusMessage = PreferenceUtils.getPrefString(mService,
			PreferenceConstants.STATUS_MESSAGE,
			mService.getString(R.string.status_online));
	int priority = PreferenceUtils.getPrefInt(mService,
			PreferenceConstants.PRIORITY, 0);
	if (messageCarbons)
		CarbonManager.getInstanceFor(mXMPPConnection).sendCarbonsEnabled(
				true);

	Presence presence = new Presence(Presence.Type.available);
	Mode mode = Mode.valueOf(statusMode);
	presence.setMode(mode);
	presence.setStatus(statusMessage);
	presence.setPriority(priority);
	mXMPPConnection.sendPacket(presence);
}
 
開發者ID:victoryckl,項目名稱:XmppTest,代碼行數:23,代碼來源:SmackImpl.java

示例8: 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

示例9: 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

示例10: login

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
public void login(String user, String pass, StatusItem status, String username)
            throws XMPPException, SmackException, IOException, InterruptedException {
        Log.i(TAG, "inside XMPP getlogin Method");
        long l = System.currentTimeMillis();
        XMPPTCPConnection connect = connect();
        if (connect.isAuthenticated()) {
            Log.i(TAG, "User already logged in");
            return;
        }

        Log.i(TAG, "Time taken to connect: " + (System.currentTimeMillis() - l));

        l = System.currentTimeMillis();
        connect.login(user, pass);
        Log.i(TAG, "Time taken to login: " + (System.currentTimeMillis() - l));

        Log.i(TAG, "login step passed");

        Presence p = new Presence(Presence.Type.available);
        p.setMode(Presence.Mode.available);
        p.setPriority(24);
        p.setFrom(connect.getUser());
        if (status != null) {
            p.setStatus(status.toJSON());
        } else {
            p.setStatus(new StatusItem().toJSON());
        }
//        p.setTo("");
        VCard ownVCard = new VCard();
        ownVCard.load(connect);
        ownVCard.setNickName(username);
        ownVCard.save(connect);

        PingManager pingManager = PingManager.getInstanceFor(connect);
        pingManager.setPingInterval(150000);
        connect.sendPacket(p);


    }
 
開發者ID:saveendhiman,項目名稱:XMPPSample_Studio,代碼行數:40,代碼來源:XMPP.java

示例11: changeStateMessage

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/** 
 * 修改心情 
 * @param connection 
 * @param status 
 */  
public static void changeStateMessage(final XMPPConnection connection,final String status)  
{  
    Presence presence = new Presence(Presence.Type.available);  
    presence.setStatus(status);  
    connection.sendPacket(presence);      
}
 
開發者ID:cowthan,項目名稱:AyoSunny,代碼行數:12,代碼來源:XmppUtil.java

示例12: testOfflineStatusPresence

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * User1 logs in, then sets offline presence information (presence with status text). User2
 * logs in and checks to see if offline presence is returned.
 *
 * @throws Exception if an exception occurs.
 */
public void testOfflineStatusPresence() throws Exception {
    // Add a new roster entry for other user.
    Roster roster = getConnection(0).getRoster();
    roster.createEntry(getBareJID(1), "gato1", null);

    // Wait up to 2 seconds
    long initial = System.currentTimeMillis();
    while (System.currentTimeMillis() - initial < 2000 && (
            roster.getPresence(getBareJID(1)).getType().equals(Presence.Type.unavailable))) {
        Thread.sleep(100);
    }

    // Sign out of conn1 with status
    Presence offlinePresence = new Presence(Presence.Type.unavailable);
    offlinePresence.setStatus("Offline test");
    getConnection(1).disconnect(offlinePresence);

    // Wait 500 ms
    Thread.sleep(500);
    Presence presence = getConnection(0).getRoster().getPresence(getBareJID(1));
    assertEquals("Offline presence status not received.", "Offline test", presence.getStatus());

    // Sign out of conn0.
    getConnection(0).disconnect();

    // See if conneciton 0 can get offline status.
    XMPPTCPConnection con0 = getConnection(0);
    con0.connect();
    con0.login(getUsername(0), getUsername(0));

    // Wait 500 ms
    Thread.sleep(500);
    presence = con0.getRoster().getPresence(getBareJID(1));
    assertTrue("Offline presence status not received after logout.",
            "Offline test".equals(presence.getStatus()));
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:43,代碼來源:PresenceTest.java

示例13: 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

示例14: changeStateMessage

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/** 
 * �޸����� 
 * @param connection 
 * @param status 
 */  
public static void changeStateMessage(final XMPPConnection connection,final String status)  
{  
    Presence presence = new Presence(Presence.Type.available);  
    presence.setStatus(status);  
    connection.sendPacket(presence);      
}
 
開發者ID:ice-coffee,項目名稱:EIM,代碼行數:12,代碼來源:XmppService.java

示例15: createPresence

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
private Presence createPresence(Presence.Mode mode) {
    String status = Preferences.getStatusMessage();
    Presence p = new Presence(Presence.Type.available);
    if (!TextUtils.isEmpty(status))
        p.setStatus(status);
    if (mode != null)
        p.setMode(mode);

    // TODO find a place for this
    p.addExtension(new CapsExtension("http://www.kontalk.org/", "none", "sha-1"));

    return p;
}
 
開發者ID:kontalk,項目名稱:androidclient,代碼行數:14,代碼來源:MessageCenterService.java


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