Package it.meucci

Class ReplyListener

java.lang.Object
it.meucci.ReplyListener
All Implemented Interfaces:
Runnable

public class ReplyListener extends Object implements Runnable
Class used to read the socket's input stream. Handles any received message.
  • Constructor Details

    • ReplyListener

      public ReplyListener()
      Creates a new reply listener. Uses `App.client` to access client's properties.
  • Method Details

    • run

      public void run()
      Inherited from Runnable interface. Describes the mechanism with which the client listens to messages. In a loop: - Reads from the socket's input stream - Serializes the message - Prints out the humanized message (cfr. Message.humanize()) - Handles the message if there's need to. (e.g. for an error without parameters such as ServerAnnouncement there is no need to handle it because printing its content to the user is more than enough)
      Specified by:
      run in interface Runnable
    • handle

      public void handle(Message message)
      Handles a received message. It first checks whether it is a Message or a Server Announcement and redirects the execution flow towards the proper method.
      Parameters:
      message - The message to be handled.