Package it.meucci
Class ReplyListener
java.lang.Object
it.meucci.ReplyListener
- All Implemented Interfaces:
Runnable
Class used to read the socket's input stream. Handles any received message.
-
Constructor Summary
Constructors -
Method Summary
-
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 asServerAnnouncement
there is no need to handle it because printing its content to the user is more than enough) -
handle
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.
-