Interface TcpClientEventHandler

  • All Known Implementing Classes:
    TcpClientEventAdapter

    public interface TcpClientEventHandler
    Defines event callbacks for monitoring the operation of a TcpClient.

    A TCP client event handler may be registered with a client to receive notifications about connection lifecycle events, reconnect attempts, sent and received agents, and received replies. Implementing this interface is optional and is not required for normal TCP client operation.

    Applications interested in only a subset of these events may extend TcpClientEventAdapter instead of implementing every method in this interface.

    Author:
    Charles B. Kozoyed
    See Also:
    TcpClient, TcpClientEventAdapter, TcpServer
    • Method Detail

      • onSocketCreated

        void onSocketCreated​(TcpClient tcpClient)
        Called when a socket has been created for the TCP client.
        Parameters:
        tcpClient - the TCP client for which the socket was created
      • onConnecting

        void onConnecting​(TcpClient tcpClient)
        Called when the TCP client begins attempting to establish a connection.
        Parameters:
        tcpClient - the TCP client attempting to connect
      • onReconnecting

        void onReconnecting​(TcpClient tcpClient)
        Called when the TCP client begins attempting to reconnect.
        Parameters:
        tcpClient - the TCP client attempting to reconnect
      • onConnectionEstablished

        void onConnectionEstablished​(TcpClient tcpClient)
        Called when the TCP client establishes a connection.
        Parameters:
        tcpClient - the TCP client that established the connection
      • onConnectionFailed

        void onConnectionFailed​(TcpClient tcpClient)
        Called when a TCP connection attempt fails.
        Parameters:
        tcpClient - the TCP client whose connection attempt failed
      • onConnectionDropped

        void onConnectionDropped​(TcpClient tcpClient,
                                 String msg,
                                 Exception ex)
        Called when an established TCP connection is dropped.
        Parameters:
        tcpClient - the TCP client whose connection was dropped
        msg - the message describing the connection drop
        ex - the exception associated with the connection drop
      • onConnectionClosed

        void onConnectionClosed​(TcpClient tcpClient)
        Called when the TCP client's connection is closed.
        Parameters:
        tcpClient - the TCP client whose connection was closed
      • onConnectionAttemptAborted

        void onConnectionAttemptAborted​(TcpClient tcpClient)
        Called when a TCP connection attempt is aborted.
        Parameters:
        tcpClient - the TCP client whose connection attempt was aborted
      • onReceivedAgent

        void onReceivedAgent​(Agent agent)
        Called when an agent is received by the TCP client.

        This callback provides notification of received agents independently of normal agent dispatch to registered API implementations.

        Parameters:
        agent - the agent received by the TCP client
      • onSendingSyncAgent

        void onSendingSyncAgent​(Agent agent)
        Called when the TCP client is sending a synchronous agent.
        Parameters:
        agent - the synchronous agent being sent
      • onReceivedReply

        void onReceivedReply​(Reply reply)
        Called when a reply is received by the TCP client.
        Parameters:
        reply - the reply received by the TCP client
      • onSendingAsyncAgent

        void onSendingAsyncAgent​(Agent agent)
        Called when the TCP client is sending an asynchronous agent.
        Parameters:
        agent - the asynchronous agent being sent
      • onWaitingToReconnect

        void onWaitingToReconnect​(TcpClient tcpClient,
                                  long waitTime)
        Called when the TCP client is waiting before another reconnection attempt.
        Parameters:
        tcpClient - the TCP client waiting to reconnect
        waitTime - the reconnect delay in milliseconds