Java 类org.jivesoftware.smackx.receipts.DeliveryReceiptManager 实例源码

项目:Zom-Android    文件:XmppConnection.java   
private void initServiceDiscovery() {
    debug(TAG, "init service discovery");
    // register connection features
    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mConnection);

    if (!sdm.includesFeature(DISCO_FEATURE))
        sdm.addFeature(DISCO_FEATURE);
    if (!sdm.includesFeature(DeliveryReceipt.NAMESPACE))
        sdm.addFeature(DeliveryReceipt.NAMESPACE);

    sdm.addFeature(HttpFileUploadManager.NAMESPACE);

    DeliveryReceiptManager.getInstanceFor(mConnection).dontAutoAddDeliveryReceiptRequests();
    DeliveryReceiptManager.getInstanceFor(mConnection).setAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode.disabled);

}
项目:lider    文件:XMPPClientImpl.java   
/**
 * Configure XMPP connection to use provided ping timeout and reply timeout.
 */
private void setServerSettings() {
    // Enable auto-connect
    ReconnectionManager.getInstanceFor(connection).enableAutomaticReconnection();
    // Set reconnection policy to increasing delay
    ReconnectionManager.getInstanceFor(connection)
            .setReconnectionPolicy(ReconnectionPolicy.RANDOM_INCREASING_DELAY);
    // Set ping interval
    PingManager.getInstanceFor(connection).setPingInterval(pingTimeout);
    // Specifies when incoming message delivery receipt requests
    // should be automatically acknowledged with a receipt.
    DeliveryReceiptManager.getInstanceFor(connection).setAutoReceiptMode(AutoReceiptMode.always);
    SmackConfiguration.setDefaultPacketReplyTimeout(packetReplyTimeout);
    logger.debug("Successfully set server settings: {} - {}", new Object[] { pingTimeout, packetReplyTimeout });
}
项目:xmpp-service    文件:XmppServiceConnection.java   
public void connect() throws IOException, XMPPException, SmackException {
    if (mConnection == null) {
        createConnection();
    }

    if (!mConnection.isConnected()) {
        Logger.info(TAG, "Connecting to " + mAccount.getHost() + ":" + mAccount.getPort());
        mConnection.connect();

        Roster roster = Roster.getInstanceFor(mConnection);
        roster.removeRosterListener(this);
        roster.addRosterListener(this);
        roster.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
        roster.setRosterLoadedAtLogin(true);
    }

    if (!mConnection.isAuthenticated()) {
        Logger.info(TAG, "Authenticating " + mAccount.getXmppJid());
        mConnection.login();

        PingManager.setDefaultPingInterval(XmppService.DEFAULT_PING_INTERVAL);
        PingManager pingManager = PingManager.getInstanceFor(mConnection);
        pingManager.registerPingFailedListener(this);

        ChatManager chatManager = ChatManager.getInstanceFor(mConnection);
        chatManager.removeChatListener(this);
        chatManager.addChatListener(this);

        DeliveryReceiptManager receipts = DeliveryReceiptManager.getInstanceFor(mConnection);
        receipts.setAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode.always);
        receipts.autoAddDeliveryReceiptRequests();
    }

    mOwnAvatar = getAvatarFor("");
}
项目:KlyphMessenger    文件:MessengerService.java   
protected void onConnectionSuccess()
{
    Log.d(TAG, "onConnectionSuccess");
    DeliveryReceiptManager.getInstanceFor(connection).enableAutoReceipts();
    isLoggedIn = true;
    //listenMsgEvents();
    listenNewChats();
    executePendingActions();
}
项目:maven-yaxim    文件:SmackableImp.java   
private void initServiceDiscovery() {
    // register connection features
    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mXMPPConnection);

    // init Entity Caps manager with storage in app's cache dir
    try {
        if (capsCacheDir == null) {
            capsCacheDir = new File(mService.getCacheDir(), "entity-caps-cache");
            capsCacheDir.mkdirs();
            EntityCapsManager.setPersistentCache(new SimpleDirectoryPersistentCache(capsCacheDir));
        }
    } catch (java.io.IOException e) {
        Log.e(TAG, "Could not init Entity Caps cache: " + e.getLocalizedMessage());
    }

    // reference PingManager, set ping flood protection to 10s
    PingManager.getInstanceFor(mXMPPConnection).setPingMinimumInterval(10*1000);

    // set Version for replies
    String app_name = mService.getString(org.yaxim.androidclient.R.string.app_name);
    String build_version[] = mService.getString(org.yaxim.androidclient.R.string.build_version).split(" ");
    Version.Manager.getInstanceFor(mXMPPConnection).setVersion(
            new Version(app_name, build_version[1], "Android"));

    // reference DeliveryReceiptManager, add listener
    DeliveryReceiptManager dm = DeliveryReceiptManager.getInstanceFor(mXMPPConnection);
    dm.enableAutoReceipts();
    dm.addReceiptReceivedListener(new ReceiptReceivedListener() { // DOES NOT WORK IN CARBONS
        public void onReceiptReceived(String fromJid, String toJid, String receiptId) {
            Log.d(TAG, "got delivery receipt for " + receiptId);
            changeMessageDeliveryStatus(receiptId, ChatConstants.DS_ACKED);
        }});
}
项目:KlyphMessenger    文件:MessengerService.java   
private void sendMessageTo(Bundle bundle)
{
    if (!connection.isConnected())
    {
        addPendingAction(ACTION_SEND_MSG, bundle);
    }
    else
    {
        String to = bundle.getString("to");
        String message = bundle.getString("message");

        to = "-" + to + "@chat.facebook.com";
        Log.d(TAG, "sendMessage to " + to + " " + message);
        Chat toChat = null;

        for (Chat chat : chats)
        {
            if (chat.getParticipant().equals(to))
            {
                toChat = chat;
            }
        }

        if (toChat == null)
        {
            toChat = createChat(to);
        }

        org.jivesoftware.smack.packet.Message msg = new org.jivesoftware.smack.packet.Message();
        msg.setBody(message);
        msg.setTo(to);
        msg.setType(org.jivesoftware.smack.packet.Message.Type.chat);
        msg.setThread(toChat.getThreadID());

        // Add to the message all the notifications requests (offline, delivered, displayed, composing)
        MessageEventManager.addNotificationsRequests(msg, true, true, true, true);
        DeliveryReceiptManager.addDeliveryReceiptRequest(msg);

        try
        {
            toChat.sendMessage(msg);
        }
        catch (XMPPException e)
        {
            e.printStackTrace();
        }
    }
}