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


Java XMPPConnection.isConnected方法代碼示例

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


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

示例1: login

import org.jivesoftware.smack.XMPPConnection; //導入方法依賴的package包/類
/**
 * 登錄
 * @param userName
 * @param password
 * @return
 */
public static XMPPConnection login(String userName,String password){
	XMPPConnection xmppConnection = createXMPPConnection();
	if (xmppConnection != null) {
		try {
			if (!xmppConnection.isConnected()) {
				xmppConnection.connect();
			}
			xmppConnection.login(userName, password);
		} catch (XMPPException e) {
			e.printStackTrace();
			xmppConnection = null;
		}
	}
	return xmppConnection;
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:22,代碼來源:XMPPUtil.java

示例2: relaseXMPPConnection

import org.jivesoftware.smack.XMPPConnection; //導入方法依賴的package包/類
/**
 * 關閉連接
 * @param xmppConnection
 */
public static void relaseXMPPConnection(XMPPConnection xmppConnection) {
    if (xmppConnection != null) {
        if (xmppConnection.isConnected()) {
            xmppConnection.disconnect();
        }
        xmppConnection = null;
    }
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:13,代碼來源:XMPPUtil.java

示例3: sample

import org.jivesoftware.smack.XMPPConnection; //導入方法依賴的package包/類
@Override
public SampleResult sample(Entry entry) {
    SampleResult res = new SampleResult();
    res.setSampleLabel(getName());
    res.setDataType(SampleResult.TEXT);
    res.setSuccessful(true);
    res.setResponseCode("200");
    res.setResponseMessage("OK");

    res.sampleStart();
    try {
        if (connConfig == null) {
            throw new RuntimeException("Cannot sample XMPP without XMPP Connection component");
        }

        XMPPConnection conn = getXMPPConnection();

        if (conn == null) {
            throw new RuntimeException("No XMPP Connection available");
        }

        String headers = "Connection ID: " + conn.getConnectionID() + "\r\n";

        String action = getAction();
        if (!conn.isConnected() && !action.equals(Connect.class.getCanonicalName())) {
            log.error("Please call Connect before calling other actions");
            throw new SmackException.NotConnectedException();
        }

        headers += "User: " + conn.getUser() + "\r\n";

        res.setRequestHeaders(headers);

        AbstractXMPPAction actObject = connConfig.getActions().get(action);
        if (actObject.perform(this, res) == null) {
            return null;
        }
    } catch (Exception e) {
        log.error("Error in XMPP Sampler: ", e);
        res.setSuccessful(false);
        res.setResponseCode("500");
        res.setResponseMessage((e.getMessage() == null || e.getMessage().isEmpty()) ? e.toString() : e.getMessage());
        res.setResponseData(ExceptionUtils.getStackTrace(e).getBytes());
    }

    res.sampleEnd();
    return res;
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:49,代碼來源:JMeterXMPPSampler.java

示例4: relaseXMPPConnection

import org.jivesoftware.smack.XMPPConnection; //導入方法依賴的package包/類
/**
 * 釋放xmppConnection
 * @param xmppConnection
 */
public static void relaseXMPPConnection(XMPPConnection xmppConnection){
	if(xmppConnection.isConnected()){
		xmppConnection.disconnect();
	}
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:10,代碼來源:XMPPUtil.java


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