当前位置: 首页>>代码示例>>Java>>正文


Java AbstractXMPPConnection类代码示例

本文整理汇总了Java中org.jivesoftware.smack.AbstractXMPPConnection的典型用法代码示例。如果您正苦于以下问题:Java AbstractXMPPConnection类的具体用法?Java AbstractXMPPConnection怎么用?Java AbstractXMPPConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbstractXMPPConnection类属于org.jivesoftware.smack包,在下文中一共展示了AbstractXMPPConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doInBackground

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
protected Boolean doInBackground(String... jid) {

            // Get the XMMPConnection from the manager
            AbstractXMPPConnection conn = XMPPConnectionManager.getConnection();
            // Obtain the PingManager associated with my XMPP connection
            this.pingManager = PingManager.getInstanceFor(conn);
            // I do not want background pings but a single foreground ping
            pingManager.setPingInterval( -1 );

            // Do the ping
            try {
                return pingManager.ping( jid[0] );
            } catch (Exception ex) {
                Log.w(LOGTAG, "XMPP error " + ex);
                this.errorMessage = "XMPP error:" + ex ;
                return false ;
            }

        }
 
开发者ID:marevalo,项目名称:FlowsManager,代码行数:20,代码来源:EntityPingActivity.java

示例2: doInBackground

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
protected EntityViewActivity doInBackground(EntityViewActivity... activity) {

            // Get the XMMPConnection from the manager
            AbstractXMPPConnection conn = XMPPConnectionManager.getConnection();
            // Obtain the ServiceDiscoveryManager associated with my XMPP connection
            this.discoManager = ServiceDiscoveryManager.getInstanceFor(conn);
            Entity entity = activity[0].myEntity;
            try {
                if ( entity.getNode() != null && entity.getNode() != "" ) {
                    activity[0].myLeafInfo = discoManager.discoverInfo( entity.getJid() , entity.getNode() );
                 } else {
                    activity[0].myLeafInfo = discoManager.discoverInfo( entity.getJid() );
                }
                Log.d(LOGTAG, "Got Info!");
            } catch (Exception ex) {
                Log.w(LOGTAG, "XMPP Disco error " + ex);
                errorMessage = ex.toString() ;
            }

            return activity[0];
        }
 
开发者ID:marevalo,项目名称:FlowsManager,代码行数:22,代码来源:EntityViewActivity.java

示例3: connect

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
@Override
public void connect(XmppURI uri, String password) throws IOException, XMPPException, SmackException {
    this.disconnect();

    XMPPTCPConnectionConfiguration configuration = XMPPTCPConnectionConfiguration.builder()
            .setUsernameAndPassword(uri.getNode(), password)
            .setServiceName(uri.getDomain())
            .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
            .setDebuggerEnabled(true)
            .build();
    AbstractXMPPConnection connection = new XMPPTCPConnection(configuration);
    connection.connect();
    connection.login();
    // keep connection alive
    // when connection is idle it will run into timeout
    PingManager pingManager = PingManager.getInstanceFor(connection);
    pingManager.setPingInterval(60);
    pingManager.pingMyServer();

    this.connection = connection;
}
 
开发者ID:citlab,项目名称:Intercloud,代码行数:22,代码来源:XmppConnectionManager.java

示例4: getConnection

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
@Override
public AbstractXMPPConnection getConnection() throws SmackException.NotConnectedException {
    if (null == this.connection) {
        logger.warn("Could not get Xmpp Connection, connection was null.");
        throw new SmackException.NotConnectedException();
    } else if (!this.connection.isConnected()) {
        try {
            // reconnect if ran into timeout
            this.connection.connect();
        } catch (Exception e) {
            this.connection = null;
            logger.error("Could not get Xmpp Connection, failed to reconnect.");
            throw new SmackException.NotConnectedException();
        }
    }
    return this.connection;
}
 
开发者ID:citlab,项目名称:Intercloud,代码行数:18,代码来源:XmppConnectionManager.java

示例5: sendRestDocument

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
@Override
public ResourceDocument sendRestDocument(XmppURI uri, ResourceDocument document) throws XMPPException, IOException, SmackException {
    AbstractXMPPConnection connection = this.connectionManager.getConnection();

    // create an set IQ stanza to uri
    RestIQ setIQ = new RestIQ(uri, document);
    // send stanza
    connection.sendStanza(setIQ);
    // wait for response
    StanzaFilter filter = new AndFilter(new IQReplyFilter(setIQ, connection));
    PacketCollector collector = connection.createPacketCollector(filter);
    IQ resultIQ = collector.nextResultOrThrow();
    if(resultIQ instanceof RestIQ) {
        // create rest doc
        return ((RestIQ) resultIQ).getResourceDocument();
    } else {
        throw new SmackException("Wrong RestIQ has been passed");
    }
}
 
开发者ID:citlab,项目名称:Intercloud,代码行数:20,代码来源:XmppService.java

示例6: getXwadlDocument

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
@Override
public ResourceTypeDocument getXwadlDocument(XmppURI uri) throws XMPPException, IOException, SmackException {
    AbstractXMPPConnection connection = this.connectionManager.getConnection();
    // create an get IQ stanza to uri
    IQ getIQ = new GetXwadlIQ(uri);

    // send stanza
    connection.sendStanza(getIQ);
    // wait for response
    StanzaFilter filter = new AndFilter(new IQReplyFilter(getIQ, connection));
    PacketCollector collector = connection.createPacketCollector(filter);
    IQ resultIQ = collector.nextResultOrThrow();
    if (resultIQ instanceof XwadlIQ) {
        // create xwadl
        return ((XwadlIQ) resultIQ).getXwadl();
    } else {
        throw new SmackException("Wrong IQ has been passed");
    }
}
 
开发者ID:citlab,项目名称:Intercloud,代码行数:20,代码来源:XmppService.java

示例7: perform

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
    if (!sampler.getXMPPConnection().isConnected()) {
        return res;
    }
    AbstractXMPPConnection conn = (AbstractXMPPConnection)sampler.getXMPPConnection();
    conn.disconnect();
    if (sampler.getXMPPConnectionConfig() != null)
        sampler.getXMPPConnectionConfig().resetConnection();
    return res;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:12,代码来源:Disconnect.java

示例8: perform

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
    AbstractXMPPConnection conn = (AbstractXMPPConnection)sampler.getXMPPConnection();
    conn.connect();
    res.setResponseData(sampler.getXMPPConnection().getConnectionID().getBytes());
    return res;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:8,代码来源:Connect.java

示例9: perform

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
    XMPPConnection conn = sampler.getXMPPConnection();
    String loginStr = sampler.getPropertyAsString(LOGIN);
    String pwdStr = sampler.getPropertyAsString(PASSWORD);
    String resStr = sampler.getPropertyAsString(RESOURCE);
    res.setSamplerData("Username: " + loginStr + "\nPassword: " + pwdStr + "\nResource: " + resStr);
    AbstractXMPPConnection absConn = (AbstractXMPPConnection) conn;
    if (loginStr.isEmpty()) {
        absConn.loginAnonymously();
    } else {
        absConn.login(loginStr, pwdStr, resStr);
    }
    return res;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:16,代码来源:Login.java

示例10: doInBackground

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
@Override
protected Boolean doInBackground(ArrayList<Entity>... entityList) {

    Entity entity = null ;

    Iterator entityIterator = entityList[0].iterator();

    // Get the XMMPConnection from the manager
    AbstractXMPPConnection conn = XMPPConnectionManager.getConnection();
    // Obtain the ServiceDiscoveryManager associated with my XMPP connection
    this.discoManager = ServiceDiscoveryManager.getInstanceFor(conn);

    while ( entityIterator.hasNext() ) {
        if (this.isCancelled()) {
            Log.d(LOGTAG , "Cancelling" );
            return null;
        }
        Log.d(LOGTAG , "Loading info for icons" );
        entity = (Entity) entityIterator.next();
        try {
            if ( entity.getNode() != null && entity.getNode() != "" ) {
                entityInfo = discoManager.discoverInfo( entity.getJid() , entity.getNode() );
            } else {
                entityInfo = discoManager.discoverInfo( entity.getJid() );
            }
        } catch (Exception ex) {
            Log.w(LOGTAG, "XMPP Disco error " + ex);
            errorMessage = ex.toString() ;
            this.publishProgress( false );
            continue;
        }
        entity.setIdentities( entityInfo.getIdentities() );
        this.publishProgress( true );
    }
    return null ;
}
 
开发者ID:marevalo,项目名称:FlowsManager,代码行数:37,代码来源:CollectionViewActivity.java

示例11: getConnection

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
public static AbstractXMPPConnection getConnection() {

        if ( XMPPConnectionManager.isConfigured == false ) {
            Log.w(LOGTAG, "Instating unconfigured connection" );
            return null;
        }
        if ( XMPPConnectionManager.isConnected == false ) {

            // Send the configuration
            // TODO: Yes I know, this is restrictive, DNS must be working
            XMPPTCPConnectionConfiguration.Builder configBuilder =
                    XMPPTCPConnectionConfiguration.builder();
            configBuilder.setUsernameAndPassword(
                    XMPPConnectionManager.xmppUserName,
                    XMPPConnectionManager.xmppPassword);
            configBuilder.setServiceName( XMPPConnectionManager.xmppUserDomain  );
            configBuilder.setResource( "FlowsManager" );

            XMPPConnectionManager.connection = new XMPPTCPConnection(configBuilder.build());

            try {
                // Create a connection to the XMPP server.
                XMPPConnectionManager.connection.connect();
                // Log into the server
                XMPPConnectionManager.connection.login();
            } catch (Exception ex) {
                Log.w(LOGTAG, "XMPP Connection error " + ex);
                return null ;
            }
            XMPPConnectionManager.isConnected = true ;

        }

        return XMPPConnectionManager.connection ;

    }
 
开发者ID:marevalo,项目名称:FlowsManager,代码行数:37,代码来源:XMPPConnectionManager.java

示例12: TestClient

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
public TestClient(AbstractXMPPConnection connection) throws XMPPErrorException, URISyntaxException, SmackException, XmlException {
	this.connection = connection;
	
	discover();
}
 
开发者ID:citlab,项目名称:Intercloud,代码行数:6,代码来源:TestClient.java

示例13: getConnection

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
public AbstractXMPPConnection getConnection() {
    return mConn;
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:4,代码来源:XMPPConnectionHelper.java

示例14: registerAccount

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
public void registerAccount(View view) {
	final EntityBareJid jid = mSettings.getJid();
	final String password = mSettings.getPassword();
	if (jid == null) {
		Toast.makeText(this, "Please enter a valid bare JID", Toast.LENGTH_SHORT).show();
		return;
	}
	if (password.isEmpty()) {
		Toast.makeText(this, "Please enter a password", Toast.LENGTH_SHORT).show();
		return;
	}
	(new Thread() {

		@Override
		public void run() {
			if (!ConnectivityManagerUtil.hasDataConnection(InfoAndSettings.this)) {
				showToast("Data connection not available", Toast.LENGTH_SHORT);
				return;
			}

			try {
				final Localpart username = jid.getLocalpart();
				final AbstractXMPPConnection connection = new XMPPTCPConnection(
						mSettings.getConnectionConfiguration(InfoAndSettings.this));
				showToast("Connecting to server", Toast.LENGTH_SHORT);
				connection.connect();
				AccountManager accountManager = AccountManager.getInstance(connection);
				showToast("Connected, trying to create account", Toast.LENGTH_SHORT);
				accountManager.createAccount(username, password);
				connection.disconnect();
			} catch (Exception e) {
				LOG.i("registerAccount", e);
				showToast("Error creating account: " + e, Toast.LENGTH_LONG);
				return;
			}
			showToast("Account created", Toast.LENGTH_SHORT);
		}

		private final void showToast(final String text, final int duration) {
			InfoAndSettings.this.runOnUiThread(new Runnable() {
				@Override
				public void run() {
					Toast.makeText(InfoAndSettings.this, text, duration).show();
				}
			});
		}

	}).start();
}
 
开发者ID:ProjectMAXS,项目名称:maxs,代码行数:50,代码来源:InfoAndSettings.java

示例15: getConnection

import org.jivesoftware.smack.AbstractXMPPConnection; //导入依赖的package包/类
AbstractXMPPConnection getConnection() throws SmackException.NotConnectedException; 
开发者ID:citlab,项目名称:Intercloud,代码行数:2,代码来源:IXmppConnectionManager.java


注:本文中的org.jivesoftware.smack.AbstractXMPPConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。