Runtime.getRuntime().addShutdownHook(shutdownHook);
reconnectionManager = new ReconnectionManager(this);
streamFeaturesManager = new StreamFeaturesManager(this);
chatManager = new ChatManager(this);
authenticationManager = new AuthenticationManager(this, lock);
authenticationManager.addFeatureListener(new StreamFeatureListener() {
@Override
public void negotiationStatusChanged(StreamFeatureEvent streamFeatureEvent) {
if (streamFeatureEvent.getStatus() == StreamFeatureNegotiator.Status.INCOMPLETE && streamFeatureEvent.getElement() instanceof Mechanisms) {
// Release the waiting thread.