1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-24 23:32:05 +01:00

Merge pull request #409 from vanitasvitae/connectionListenerConnecting

ConnectionListener: Add connecting(XMPPConnection) method.
This commit is contained in:
Florian Schmaus 2020-07-23 14:19:14 +02:00 committed by GitHub
commit f1e10bc6bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View file

@ -514,6 +514,9 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
// Check if not already connected // Check if not already connected
throwAlreadyConnectedExceptionIfAppropriate(); throwAlreadyConnectedExceptionIfAppropriate();
// Notify connection listeners that we are trying to connect
callConnectionConnectingListener();
// Reset the connection state // Reset the connection state
initState(); initState();
closingStreamReceived = false; closingStreamReceived = false;
@ -1680,6 +1683,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
} }
} }
protected void callConnectionConnectingListener() {
for (ConnectionListener listener : connectionListeners) {
listener.connecting(this);
}
}
protected void callConnectionConnectedListener() { protected void callConnectionConnectedListener() {
for (ConnectionListener listener : connectionListeners) { for (ConnectionListener listener : connectionListeners) {
listener.connected(this); listener.connected(this);

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2003-2007 Jive Software. * Copyright 2003-2007 Jive Software, 2020 Paul Schaub
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,6 +28,16 @@ package org.jivesoftware.smack;
*/ */
public interface ConnectionListener { public interface ConnectionListener {
/**
* Notification that the connection is in the process of connecting.
* This method is called when {@link AbstractXMPPConnection#connect()} is executed.
*
* @param connection connection
* @since 4.4
*/
default void connecting(XMPPConnection connection) {
}
/** /**
* Notification that the connection has been successfully connected to the remote endpoint (e.g. the XMPP server). * Notification that the connection has been successfully connected to the remote endpoint (e.g. the XMPP server).
* <p> * <p>