本文整理汇总了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);
}
});
}
示例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);
}
});
}
示例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();
}
});
}
示例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();
}
});
}
示例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();
}