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


Java Presence.setPriority方法代碼示例

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


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

示例1: sendPriorityPresence

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * This method sends a {@link Presence} packet with the configured priority.
 */
private void sendPriorityPresence() {
    if (!connection.isConnected()) {
        return;
    }
    int priority = CommunoteRuntime.getInstance().getConfigurationManager()
            .getApplicationConfigurationProperties()
            .getProperty(ApplicationPropertyXmpp.PRIORITY, 100);
    Presence presence = new Presence(Presence.Type.available);
    presence.setPriority(priority);
    try {
        connection.sendPacket(presence);
    } catch (NotConnectedException e) {
        LOG.info("Could not send presence packet because XMPP connector is disconnected");
    }
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:19,代碼來源:XMPPConnector.java

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

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

示例4: sendSubscriptionRequest

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * This method sends a subscription request to the sender.
 *
 * @param presence
 *            The presence used for sender and receiver information.
 * @throws NotConnectedException
 */
private void sendSubscriptionRequest(Presence presence) throws NotConnectedException {
    int priority = CommunoteRuntime.getInstance().getConfigurationManager()
            .getApplicationConfigurationProperties()
            .getProperty(ApplicationPropertyXmpp.PRIORITY, 100);
    Presence subscription = new Presence(Presence.Type.subscribe);
    subscription.setPriority(priority);
    subscription.setFrom(presence.getTo());
    subscription.setTo(presence.getFrom());
    presence.setType(Presence.Type.subscribed);
    presence.setFrom(subscription.getFrom());
    presence.setTo(subscription.getTo());
    connection.sendPacket(presence);
    connection.sendPacket(subscription);
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:22,代碼來源:XMPPPresencePacketListener.java

示例5: sendPresence

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
 * change jabber status. Example: sendPresencePacket(Presence.Type.AVAILABLE, "at meeting...", 1, Presence.Mode.AWAY);
 * 
 * @param type
 * @param status
 * @param priority
 * @param mode
 */
public void sendPresence(final Presence.Type type, String status, final int priority, final Presence.Mode mode) {
    // get rid of "&" because they break xml packages!
    if (status != null) {
        status = status.replaceAll("&", "&");
    }
    if (connection == null || !connection.isConnected()) {
        return;
    }
    if (collaborationDisabled) {
        return;
    }

    setStatus(mode);
    final Presence presence = new Presence(type);
    if (status == null) {
        if (mode == Presence.Mode.available) {
            status = InstantMessagingConstants.PRESENCE_MODE_AVAILABLE;
        } else if (mode == Presence.Mode.away) {
            status = InstantMessagingConstants.PRESENCE_MODE_AWAY;
        } else if (mode == Presence.Mode.chat) {
            status = InstantMessagingConstants.PRESENCE_MODE_CHAT;
        } else if (mode == Presence.Mode.dnd) {
            status = InstantMessagingConstants.PRESENCE_MODE_DND;
        } else if (mode == Presence.Mode.xa) {
            status = InstantMessagingConstants.PRESENCE_MODE_XAWAY;
        }
        presence.setStatus(status);
    } else {
        presence.setStatus(status);
    }
    setStatusMsg(presence.getStatus());
    // setting prio when type == unavailable causes error on IM server
    if (presence.getType() == Presence.Type.available) {
        presence.setPriority(priority);
    }
    if (mode != null) {
        presence.setMode(mode);
    }
    try {
        connection.sendPacket(presence);
    } catch (final RuntimeException ex) {
        log.warn("Error while trying to send Instant Messaging packet for user: " + userInfo.getUsername() + " .Errormessage: ", ex);
    }
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:53,代碼來源:InstantMessagingClient.java

示例6: handlePresence

import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
@CommandHandler(name = ACTION_PRESENCE)
private boolean handlePresence(Intent intent, boolean canConnect) {
    if (canConnect && isConnected()) {
        final String id = intent.getStringExtra(EXTRA_PACKET_ID);
        String type = intent.getStringExtra(EXTRA_TYPE);
        final String to = intent.getStringExtra(EXTRA_TO);

        if ("probe".equals(type)) {
            // probing is actually looking into the roster
            final Roster roster = getRoster();

            if (to == null) {
                for (RosterEntry entry : roster.getEntries()) {
                    broadcastPresence(roster, entry, id);
                }

                // broadcast our own presence
                broadcastMyPresence(id);
            }
            else {
                queueTask(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            broadcastPresence(roster, JidCreate.bareFrom(to), id);
                        }
                        catch (XmppStringprepException e) {
                            Log.w(TAG, "error parsing JID: " + e.getCausingString(), e);
                            // report it because it's a big deal
                            ReportingManager.logException(e);
                            throw new IllegalArgumentException(e);
                        }
                    }
                });
            }
        }
        else {
            // FIXME isn't this somewhat the same as createPresence?
            String show = intent.getStringExtra(EXTRA_SHOW);
            Presence p = new Presence(type != null ? Presence.Type.valueOf(type) : Presence.Type.available);
            p.setStanzaId(id);
            if (to != null)
                p.setTo(to);
            if (intent.hasExtra(EXTRA_PRIORITY))
                p.setPriority(intent.getIntExtra(EXTRA_PRIORITY, 0));
            String status = intent.getStringExtra(EXTRA_STATUS);
            if (!TextUtils.isEmpty(status))
                p.setStatus(status);
            if (show != null)
                p.setMode(Presence.Mode.valueOf(show));

            sendPacket(p);
        }
    }

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


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