Interface ConnectionCloseListener


public interface ConnectionCloseListener
Implement and register this listener with a connection to receive notifications when the connection is closed. Important: A connection closing does not necessarily imply that the associated session has been closed as well. In some cases, a session may outlive its connection - for example, when Stream Management is enabled. Implementations MUST NOT assume that a callback to any method in this interface indicates that the corresponding session has been closed. To reliably detect session closure events, implementations should instead use SessionEventListener. Listener Execution Order Listeners are executed in order of their priority, with higher priority values being executed first. Built-in listeners (such as those for client, server, or component sessions) use high priority values. Third-party listeners should use the default priority (0) or a low positive value to ensure they are executed after built-in listeners. This guarantees that critical cleanup logic (e.g., session removal from routing tables) occurs before any other listeners are invoked.
Author:
Iain Shigeoka, Guus der Kinderen, guus@goodbytes.nl
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The priority used by Openfire's built-in listeners.
    static final int
    The recommended priority for third-party implementations.
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    Returns the priority of this listener.
    Called when a connection is being closed.
  • Field Details

    • PRIO_BUILT_IN

      static final int PRIO_BUILT_IN
      The priority used by Openfire's built-in listeners. These should generally be higher than those implemented by third parties / in plugins. This guarantees that critical cleanup logic (e.g., session removal from routing tables) occurs before any other listeners are invoked.
      See Also:
    • PRIO_THIRDPARTY

      static final int PRIO_THIRDPARTY
      The recommended priority for third-party implementations. These should generally be lower than the priority used by Openfire's built-in implementations. This guarantees that critical cleanup logic (e.g., session removal from routing tables) occurs before any other listeners are invoked.
      See Also:
  • Method Details

    • onConnectionClosing

      CompletableFuture<Void> onConnectionClosing(@Nullable Object handback)
      Called when a connection is being closed. This method is intended to be used to start asynchronous processes. The Future that is returned is to be used to status of such an asynchronous process.
      Parameters:
      handback - The handback object associated with the connection listener during Connection.registerCloseListener()
      Returns:
      a Future representing pending completion of the event listener invocation.
    • getPriority

      default int getPriority()
      Returns the priority of this listener. Listeners with higher priority values are executed before listeners with lower priority values. Built-in listeners (such as those for client, server, or component sessions) use high priority values (e.g., 100) and should generally be executed before any third-party listeners. Third-party listeners are encouraged to use the default priority (0) or a low positive value to ensure they are executed after built-in listeners.
      Returns:
      the priority of this listener