Class Command
java.lang.Object
Command
public abstract class Command extends Object
Represents a command string sent from a client to the server, after it has been parsed into a
more convenient form. The
Command
abstract class has a concrete subclass corresponding to
each of the possible commands that can be issued by a client. The protocol specification contains
more information about the expected behavior of various commands.-
Method Summary
Modifier and Type Method Description boolean
equals(Object o)
Returnstrue
if twoCommand
s are equal; that is, they produce the same string representation.String
getSender()
Gets the nickname of the client who issued theCommand
.int
getSenderId()
Gets the user ID of the client who issued theCommand
.abstract Broadcast
updateServerModel(ServerModel model)
Processes the command and updates the server model accordingly.
-
Method Details
-
getSenderId
public int getSenderId()Gets the user ID of the client who issued theCommand
.- Returns:
- The user ID of the client who issued this command
-
getSender
Gets the nickname of the client who issued theCommand
.- Returns:
- The nickname of the client who issued this command
-
updateServerModel
Processes the command and updates the server model accordingly.- Parameters:
model
- An instance of theServerModelApi
class which represents the current state of the server.- Returns:
- A
Broadcast
object, informing clients about changes resulting from the command.
-
equals
Returnstrue
if twoCommand
s are equal; that is, they produce the same string representation.
-