Class AsyncService

  • All Implemented Interfaces:
    java.lang.Runnable
    Direct Known Subclasses:
    AuthenticationProtocolServer, ConnectionProtocol

    public abstract class AsyncService
    extends Service
    implements java.lang.Runnable

    Extends the simple Service class to provide an asyncronous messaging service for the transport protocol.

    Since:
    0.2.0
    Version:
    $Revision: 1.28 $
    Author:
    Lee David Painter
    • Constructor Detail

      • AsyncService

        public AsyncService​(java.lang.String serviceName)

        Constructs an asyncronous service.

        Parameters:
        serviceName - the name of the service
        Since:
        0.2.0
    • Method Detail

      • onStart

        protected void onStart()
                        throws java.io.IOException

        Implements the abstract Service method and starts the service thread.

        Specified by:
        onStart in class Service
        Throws:
        java.io.IOException - if an IO error occurs
        Since:
        0.2.0
      • run

        public final void run()

        Implements the asyncronous services message loop.

        Specified by:
        run in interface java.lang.Runnable
        Since:
        0.2.0
      • onStop

        protected abstract void onStop()

        The service thread calls this method when the thread is exiting.

        Since:
        0.2.0
      • getAsyncMessageFilter

        protected abstract int[] getAsyncMessageFilter()

        Implement this method by returning the message ids of the asyncrounous messages your implementation wants to receive.

        Returns:
        an int array of message ids
        Since:
        0.2.0
      • onMessageReceived

        protected abstract void onMessageReceived​(SshMessage msg)
                                           throws java.io.IOException

        Called by the service thread when an asyncronous message is received.

        Parameters:
        msg - the message received
        Throws:
        java.io.IOException - if an IO error occurs
        Since:
        0.2.0