Package it.fi.meucci.utils
Enum Class ServerAnnouncement
- All Implemented Interfaces:
Serializable
,Comparable<ServerAnnouncement>
,Constable
Represents the types of Server Announcement a message of type SERVER_ANN can have.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionSent when the command issued by the user is not valid nor recognizedSent when a message doesn't have a valid addresseeSent as a confirmation to the `DISCONNECT` commandCommandType
Sent when a new user joins the serverSent when a user lefts the serverSent when the server sends a list of connected usernamesSent when the user requesting a new username has inserted a not valid one.Sent when the user requesting a new username has inserted a valid one.Sent when the user attempting to send a message doesn't have a valid username set.Sent when the username of a user successfully changed -
Method Summary
Modifier and TypeMethodDescriptionstatic Message
createJoinedAnnouncement
(String joined) Creates a new JOINED messagestatic Message
createLeftAnnouncement
(String left) Creates a LEFT messagestatic Message
createListAnnouncement
(ArrayList<String> utenti, String to) Creates a new LIST announcementstatic Message
Creates a new Server announcementstatic Message
createUsernameChangedAnnouncement
(String before, String after) Creates a CHANGE USERNAME messagestatic ServerAnnouncement
Returns the enum constant of this class with the specified name.static ServerAnnouncement[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
JOINED
Sent when a new user joins the server -
LEFT
Sent when a user lefts the server -
NAME_OK
Sent when the user requesting a new username has inserted a valid one. -
NAME_NOT_OK
Sent when the user requesting a new username has inserted a not valid one. -
NEED_NAME
Sent when the user attempting to send a message doesn't have a valid username set. -
LIST
Sent when the server sends a list of connected usernames -
DEST_NOT_CORRECT
Sent when a message doesn't have a valid addressee -
DISCONNECT
Sent as a confirmation to the `DISCONNECT` commandCommandType
-
COMMAND_NOT_RECOGNIZED
Sent when the command issued by the user is not valid nor recognized -
USERNAME_CHANGED
Sent when the username of a user successfully changed
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
createListAnnouncement
Creates a new LIST announcement- Parameters:
utenti
- the list of usernames currently connectedto
- The addressee- Returns:
- A LIST message
-
createServerAnnouncement
Creates a new Server announcement- Parameters:
t
- The Type of the announcementServerAnnouncement
to
- The addressee- Returns:
- The newly created announcement
-
createJoinedAnnouncement
Creates a new JOINED message- Parameters:
joined
- the string of the new user's username- Returns:
- a JOINED message
-
createLeftAnnouncement
Creates a LEFT message- Parameters:
left
- the left user's username- Returns:
- a LEFT message
-
createUsernameChangedAnnouncement
Creates a CHANGE USERNAME message- Parameters:
before
- The username before the changeafter
- The username after the change- Returns:
- a CHANGE_USERNAME message
-