1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 18:59:41 +02:00

SMACK-458 Managers should be kept on disconnects

Smack's Managers should not remove itself when the connection is closed
or should re-add themselves if the connection get reconnected.

This should also fix some NPE's.

We are currently going with two different designs of Manager: 1. The one
with WeakReferences/WeakHashMaps (SDM, EntityCapsManager) and 2. the one
where the managers remove their listeners on connectionClosed() *and*
connectionClosedOnError(), and later add their listeners on
reconnectionSuccessful(). The first design has the Connection instance
only weak referenced. The other design does reference Connection
strongly (e.g. the 'managers' map in IBBManager/S5BManager), but removes
this references when connectionClosed(onError)() is called.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_2@13788 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Florian Schmaus 2013-10-26 11:17:16 +00:00 committed by flow
parent 032fc8626e
commit b16f34f61e
12 changed files with 298 additions and 369 deletions

View file

@ -89,21 +89,27 @@ public final class Socks5BytestreamManager implements BytestreamManager {
static {
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(Connection connection) {
final Socks5BytestreamManager manager;
manager = Socks5BytestreamManager.getBytestreamManager(connection);
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() {
manager.disableService();
Socks5BytestreamManager.getBytestreamManager(connection).disableService();
}
@Override
public void connectionClosedOnError(Exception e) {
manager.disableService();
Socks5BytestreamManager.getBytestreamManager(connection).disableService();
}
@Override
public void reconnectionSuccessful() {
// re-create the manager for this connection
Socks5BytestreamManager.getBytestreamManager(connection);
}
});
@ -274,7 +280,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
/**
* Disables the SOCKS5 Bytestream manager by removing the SOCKS5 Bytestream feature from the
* service discovery, disabling the listener for SOCKS5 Bytestream initiation requests and
* resetting its internal state.
* resetting its internal state, which includes removing this instance from the managers map.
* <p>
* To re-enable the SOCKS5 Bytestream feature invoke {@link #getBytestreamManager(Connection)}.
* Using the file transfer API will automatically re-enable the SOCKS5 Bytestream feature.