Package it.fi.meucci
Class Handler
java.lang.Object
it.fi.meucci.Handler
This class contains all the methods needed to send and to manage messages.
They are called by Request Listener class and can't be instantiated.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
General purpose handler that automatically throws an exceptionstatic void
handleCommand
(Message msg) Handles a Command.static void
handleMessage
(Message msg) Handles a Message
-
Constructor Details
-
Handler
public Handler()
-
-
Method Details
-
handleMessage
public static void handleMessage(Message msg) throws NeedNameException, DestNotCorrectException, IOException Handles a Message- Parameters:
msg
- The message to be handled- Throws:
NeedNameException
- When the message does not have a valid senderDestNotCorrectException
- When the message does not have a valid receiverIOException
- When it's unable to send the message on the socket's output stream
-
handleCommand
public static void handleCommand(Message msg) throws NeedNameException, DestNotCorrectException, DisconnectException, CommandNotRecognizedException Handles a Command. Checks if the message has a correct addressee and a correct sender.- Parameters:
msg
- The command to be handled- Throws:
NeedNameException
- When the name does not have a valid senderDestNotCorrectException
- When the name does not have a valid addresseeDisconnectException
- When the user asked to disconnectCommandNotRecognizedException
- When the command sent by the user is not valid
-
handle
General purpose handler that automatically throws an exception- Parameters:
msg
- The message to be handled- Throws:
HandlerException
- A Command Not Recognized Exception
-