Class 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 Details

    • getSenderId

      public int getSenderId()
      Gets the user ID of the client who issued the Command.
      Returns:
      The user ID of the client who issued this command
    • getSender

      public String getSender()
      Gets the nickname of the client who issued the Command.
      Returns:
      The nickname of the client who issued this command
    • updateServerModel

      public abstract Broadcast updateServerModel​(ServerModel model)
      Processes the command and updates the server model accordingly.
      Parameters:
      model - An instance of the ServerModelApi class which represents the current state of the server.
      Returns:
      A Broadcast object, informing clients about changes resulting from the command.
    • equals

      public boolean equals​(Object o)
      Returns true if two Commands are equal; that is, they produce the same string representation.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare with this for equality
      Returns:
      true iff both objects are non-null and equal to each other