RPCConnectionListener
Keywords: net.corda.client.rpc.ext.RPCConnectionListener interface
Date: 2023-09-18

net.corda.client.rpc.ext

## Interface RPCConnectionListener<I extends RPCOps>

-     public RPCConnectionListener<I extends RPCOps>

  A listener that can be attached to `class MultiRPCClient` to be notified about important RPC connectivity events.

  See Also:
    `class MultiRPCClient`

- - ### Constructor Detail

    - #### RPCConnectionListener

          public RPCConnectionListener()

  - ### Method Detail

    - #### onConnect

          void onConnect(@NotNull
                         net.corda.client.rpc.ext.RPCConnectionListener.ConnectionContext<I> context)

      This method will be called to inform that RPC connection is established. `ConnectionContext.connectionOpt` will not be `null`.

      If connection is lost RPC client will attempt to re-connect and if this is successful then this method will be called again with the same reference of `ConnectionContext.connectionOpt` as during initial connect. I.e. it is possible to say that once established `ConnectionContext.connectionOpt` stays constant during `onConnect`/`onDisconnect` cycles.

      See Also:
        `ConnectionContext.connectionOpt`, `ConnectionContext.connectionOpt`, `ConnectionContext.connectionOpt`, `onConnect`, `onDisconnect`

    - #### onDisconnect

          void onDisconnect(@NotNull
                            net.corda.client.rpc.ext.RPCConnectionListener.ConnectionContext<I> context)

      This method will be called to inform about connection loss. Since given RPC client may produce multiple `interface RPCConnection`s, `ConnectionContext.connectionOpt` will specify which connection is interrupted.

      See Also:
        `interface RPCConnection`, `ConnectionContext.connectionOpt`

    - #### onPermanentFailure

          void onPermanentFailure(@NotNull
                                  net.corda.client.rpc.ext.RPCConnectionListener.ConnectionContext<I> context)

      This is a terminal notification to inform that:

      - it has never been possible to connect due to incorrect credentials or endpoints addresses supplied. In this case `ConnectionContext.connectionOpt` will be `null`; or

      - no further reconnection will be performed as maximum number of attempts has been reached. In this case `ConnectionContext.connectionOpt` may not be `null`.

      See Also:
        `ConnectionContext.connectionOpt`, `ConnectionContext.connectionOpt`