/** * Constructor. * * @param connection the XMPP connection */ private InBandBytestreamManager(Connection connection) { this.connection = connection; // register bytestream open packet listener initiationListener = new InitiationListener(this); this.connection.addPacketListener(initiationListener, initiationListener.getFilter()); // register bytestream data packet listener dataListener = new DataListener(this); this.connection.addPacketListener(dataListener, dataListener.getFilter()); // register bytestream close packet listener closeListener = new CloseListener(this); this.connection.addPacketListener(closeListener, closeListener.getFilter()); }
/** * Disables the InBandBytestreamManager by removing its packet listeners and resetting its * internal status. */ private void disableService() { // remove manager from static managers map managers.remove(connection); // remove all listeners registered by this manager connection.removePacketListener(initiationListener); connection.removePacketListener(dataListener); connection.removePacketListener(closeListener); // shutdown threads initiationListener.shutdown(); // reset internal status userListeners.clear(); allRequestListeners.clear(); sessions.clear(); ignoredBytestreamRequests.clear(); }