Interface MessageHandler


  • public interface MessageHandler
    A message handler for asynchronous protocol messages.
    Author:
    David M. Lloyd
    • Method Detail

      • handleMessage

        void handleMessage​(Connection connection,
                           InputStream dataStream)
                    throws IOException
        Handle a message.
        Parameters:
        connection - the connection to the remote side
        dataStream - the message bytes
        Throws:
        IOException - if an I/O error occurs
      • handleShutdown

        void handleShutdown​(Connection connection)
                     throws IOException
        Handle the end-of-input condition. The write side will still be writable.
        Parameters:
        connection - the connection to the remote side
        Throws:
        IOException - if an I/O error occurs
      • handleFailure

        void handleFailure​(Connection connection,
                           IOException e)
                    throws IOException
        Handle an input failure condition. The write side is unlikely to be writable. When a failure is encountered, the socket should usually be Connection.close()d.
        Parameters:
        connection - the connection to the remote side
        e - the read error received
        Throws:
        IOException - if an I/O error occurs
      • handleFinished

        void handleFinished​(Connection connection)
                     throws IOException
        Handle the condition where a connection is completely finished (both reads and writes). This is where any reconnect logic should live.
        Parameters:
        connection - the connection that ended
        Throws:
        IOException - if an I/O error occurs