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


Java XMPPTCPConnection.addConnectionListener方法代碼示例

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


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

示例1: XMPPConnector

import org.jivesoftware.smack.tcp.XMPPTCPConnection; //導入方法依賴的package包/類
/**
 * The constructor for the XMPP bot.
 *
 * @param host
 *            The server the bot should login.
 * @param port
 *            The hosts port.
 * @param login
 *            The bots login name.
 * @param password
 *            The bots login password.
 * @param resource
 *            The bots resource (i.e. Work or Home). Can be null.
 * @throws IllegalArgumentException
 *             Throws an {@link IllegalArgumentException} if some of the parameters are in an
 *             invalid format.
 */
public XMPPConnector(String host, String port, String login, String password, String resource)
        throws IllegalArgumentException {
    checkParameters(host, port, login, password, resource);
    int numericalPort = port == null ? DEFAULT_XMPP_PORT : Integer.parseInt(port);
    this.sender = login + "@" + host + "/" + resource;
    SmackConfiguration.DEBUG_ENABLED = Boolean.parseBoolean(ApplicationPropertyXmpp.DEBUG
            .getValue());
    ProviderManager.addExtensionProvider(AliasPacketExtension.ALIAS_ELEMENT_NAME,
            AliasPacketExtension.ALIAS_NAMESPACE, AliasPacketExtension.class);
    ConnectionConfiguration config = new ConnectionConfiguration(host, numericalPort);
    connection = new XMPPTCPConnection(config);
    connect(login, password, resource);
    sendPriorityPresence();
    if (connection.isConnected()) {
        LOG.info(ResourceBundleManager.instance().getText("xmpp.connection.started",
                Locale.ENGLISH));
        connection.addConnectionListener(new XMPPConnectionStatusLogger());
    } else {
        LOG.info("The XMPP connection wasn't established.");
    }
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:39,代碼來源:XMPPConnector.java

示例2: initGroupConnection

import org.jivesoftware.smack.tcp.XMPPTCPConnection; //導入方法依賴的package包/類
private void initGroupConnection() {
    long currentUserId = CurrentUser.getInstance().getCurrentUserId();
    String currentUserPassword = CurrentUser.getInstance().getCurrentPassword();
    String jid = currentUserId + "-" + ApiConstants.APP_ID;
    groupChatConnection = new XMPPTCPConnection(
            jid, currentUserPassword, ApiConstants.MULTI_USERS_CHAT_ENDPOINT);
    groupChatConnection.addConnectionListener(this);
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:9,代碼來源:QuickbloxGroupXmppConnection.java

示例3: initPrivateConnection

import org.jivesoftware.smack.tcp.XMPPTCPConnection; //導入方法依賴的package包/類
private void initPrivateConnection() {
    long currentUserId = CurrentUser.getInstance().getCurrentUserId();
    String currentUserPassword = CurrentUser.getInstance().getCurrentPassword();
    String userName = currentUserId + "-" + ApiConstants.APP_ID;
    XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
    configBuilder.setUsernameAndPassword(userName, currentUserPassword);
    configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
    configBuilder.setServiceName(ApiConstants.CHAT_END_POINT);
    configBuilder.setHost(ApiConstants.CHAT_END_POINT);
    configBuilder.setDebuggerEnabled(true);

    privateChatConnection = new XMPPTCPConnection(configBuilder.build());
    privateChatConnection.addConnectionListener(this);

    ReconnectionManager manager = ReconnectionManager.getInstanceFor(privateChatConnection);
    manager.enableAutomaticReconnection();
    manager.setReconnectionPolicy(ReconnectionManager.ReconnectionPolicy.FIXED_DELAY);
    manager.setFixedDelay(15);

    ProviderManager.addExtensionProvider(Displayed.ELEMENT, Displayed.NAMESPACE, new Displayed.Provider());
    DisplayedManager.getInstanceFor(privateChatConnection).addDisplayedListener(
            (fromJid, toJid, receiptId, receipt) -> {
                messageService.get().processDisplayed(fromJid, toJid, receiptId, receipt);
            });

    ProviderManager.addExtensionProvider(Received.ELEMENT, Received.NAMESPACE, new Received.Provider());
    ReceivedManager.getInstanceFor(privateChatConnection).addReceivedListener(
            (fromJid, toJid, receiptId, receipt) -> {
                messageService.get().processReceived(fromJid, toJid, receiptId, receipt);
            });
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:32,代碼來源:QuickbloxPrivateXmppConnection.java

示例4: createConnection

import org.jivesoftware.smack.tcp.XMPPTCPConnection; //導入方法依賴的package包/類
private void createConnection() {
    Logger.debug(TAG, "creating new connection to " + mAccount.getHost() + ":" + mAccount.getPort());

    XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder()
            .setServiceName(mAccount.getServiceName())
            .setResource(mAccount.getResourceName())
            .setHost(mAccount.getHost())
            .setPort(mAccount.getPort())
            .setUsernameAndPassword(mAccount.getXmppJid(), mAccount.getPassword())
            .setConnectTimeout(XmppService.CONNECT_TIMEOUT);

    if (XmppService.CUSTOM_SSL_CONTEXT != null) {
        Logger.debug(TAG, "setting custom SSL context");
        builder.setCustomSSLContext(XmppService.CUSTOM_SSL_CONTEXT);
    }

    if (XmppService.CUSTOM_HOSTNAME_VERIFIER != null) {
        Logger.debug(TAG, "setting custom hostname verifier");
        builder.setHostnameVerifier(XmppService.CUSTOM_HOSTNAME_VERIFIER);
    }

    mConnection = new XMPPTCPConnection(builder.build());
    mConnection.setUseStreamManagement(XmppService.USE_STREAM_MANAGEMENT);
    mConnection.setUseStreamManagementResumption(XmppService.USE_STREAM_MANAGEMENT);
    mConnection.setPreferredResumptionTime(XmppService.STREAM_MANAGEMENT_RESUMPTION_TIME);

    mConnection.addConnectionListener(this);
}
 
開發者ID:VoiSmart,項目名稱:xmpp-service,代碼行數:29,代碼來源:XmppServiceConnection.java

示例5: XMPPManager

import org.jivesoftware.smack.tcp.XMPPTCPConnection; //導入方法依賴的package包/類
private XMPPManager() {
    config = new ConnectionConfiguration(serverAddress, 5222, serverName);
    config.setReconnectionAllowed(true);
    config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
    connection = new XMPPTCPConnection(config);
    connection.addConnectionListener(new XMPPConnectionListener());
}
 
開發者ID:gongmingqm10,項目名稱:SmackDemo,代碼行數:8,代碼來源:XMPPManager.java

示例6: connect

import org.jivesoftware.smack.tcp.XMPPTCPConnection; //導入方法依賴的package包/類
public void connect() throws IOException, XMPPException, SmackException {
    Log.i(TAG, "connect()");

    XMPPTCPConnectionConfiguration.XMPPTCPConnectionConfigurationBuilder builder = XMPPTCPConnectionConfiguration.builder();
    builder.setServiceName(mServiceName);
    builder.setResource("SmackAndroidTestClient");
    builder.setUsernameAndPassword(mUsername, mPassword);
    builder.setRosterLoadedAtLogin(true);


    mConnection = new XMPPTCPConnection(builder.build());

    //Set ConnectionListener here to catch initial connect();
    mConnection.addConnectionListener(this);

    mConnection.connect();
    mConnection.login();

    PingManager.setDefaultPingInterval(600); //Ping every 10 minutes
    PingManager pingManager = PingManager.getInstanceFor(mConnection);
    pingManager.registerPingFailedListener(this);

    setupSendMessageReceiver();

    ChatManager.getInstanceFor(mConnection).addChatListener(this);
    mConnection.getRoster().addRosterListener(this);

}
 
開發者ID:meisterfuu,項目名稱:SmackAndroidDemo,代碼行數:29,代碼來源:SmackConnection.java


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