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


Java Connection.addConnectionListener方法代码示例

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


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

示例1: connectionCreated

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
public void connectionCreated(final Connection connection) {
    // create the manager for this connection
    InBandBytestreamManager.getByteStreamManager(connection);

    // register shutdown listener
    connection.addConnectionListener(new AbstractConnectionListener() {

        @Override
        public void connectionClosed() {
            InBandBytestreamManager.getByteStreamManager(connection).disableService();
        }

        @Override
        public void connectionClosedOnError(Exception e) {
            InBandBytestreamManager.getByteStreamManager(connection).disableService();
        }

        @Override
        public void reconnectionSuccessful() {
            // re-create the manager for this connection
            InBandBytestreamManager.getByteStreamManager(connection);
        }
    });

}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:26,代码来源:InBandBytestreamManager.java

示例2: connectionCreated

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
public void connectionCreated(final Connection connection) {
    // create the manager for this connection
    Socks5BytestreamManager.getBytestreamManager(connection);

    // register shutdown listener
    connection.addConnectionListener(new AbstractConnectionListener() {

        @Override
        public void connectionClosed() {
            Socks5BytestreamManager.getBytestreamManager(connection).disableService();
        }

        @Override
        public void connectionClosedOnError(Exception e) {
            Socks5BytestreamManager.getBytestreamManager(connection).disableService();
        }

        @Override
        public void reconnectionSuccessful() {
            // re-create the manager for this connection
            Socks5BytestreamManager.getBytestreamManager(connection);
        }
    });
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:25,代码来源:Socks5BytestreamManager.java

示例3: connectionCreated

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
public void connectionCreated(Connection connection) {
    final InBandBytestreamManager manager;
    manager = InBandBytestreamManager.getByteStreamManager(connection);

    // register shutdown listener
    connection.addConnectionListener(new AbstractConnectionListener() {

        public void connectionClosed() {
            manager.disableService();
        }

    });

}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:15,代码来源:InBandBytestreamManager.java

示例4: connectionCreated

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
public void connectionCreated(Connection connection) {
    final Socks5BytestreamManager manager;
    manager = Socks5BytestreamManager.getBytestreamManager(connection);

    // register shutdown listener
    connection.addConnectionListener(new AbstractConnectionListener() {

        public void connectionClosed() {
            manager.disableService();
        }

    });
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:14,代码来源:Socks5BytestreamManager.java

示例5: PingManager

import org.jivesoftware.smack.Connection; //导入方法依赖的package包/类
private PingManager(final Connection connection) {
    this.connection = connection;
    instances.put(connection, this);

    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
    sdm.addFeature(NAMESPACE);

    PacketFilter pingPacketFilter = new PacketTypeFilter(Ping.class);
    connection.addPacketListener(new PacketListener() {
        /**
         * Sends a Pong for every Ping
         */
        public void processPacket(Packet packet) {
            if (pingMinDelta > 0) {
                // Ping flood protection enabled
                long currentMillies = System.currentTimeMillis();
                long delta = currentMillies - lastPingStamp;
                lastPingStamp = currentMillies;
                if (delta < pingMinDelta) {
                    return;
                }
            }
            Pong pong = new Pong((Ping)packet);
            connection.sendPacket(pong);
        }
    }
    , pingPacketFilter);
    connection.addConnectionListener(new ConnectionListener() {

        @Override
        public void connectionClosed() {
            maybeStopPingServerTask();
        }

        @Override
        public void connectionClosedOnError(Exception arg0) {
            maybeStopPingServerTask();
        }

        @Override
        public void reconnectionSuccessful() {
            maybeSchedulePingServerTask();
        }

        @Override
        public void reconnectingIn(int seconds) {
        }

        @Override
        public void reconnectionFailed(Exception e) {
        }
    });
    maybeSchedulePingServerTask();
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:55,代码来源:PingManager.java


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