java.lang.Object
cmpt213.assignment4.packagedeliveries.client.control.ServerConnection

public class ServerConnection extends Object
This class establishes connection to the server and has methods to handle requests.
  • Field Details

  • Constructor Details

    • ServerConnection

      public ServerConnection()
      Constructor for this class. On constructor call starts connection with server.
  • Method Details

    • getMessage

      public String getMessage(String command)
      Method that allows client to sent GET messages to the server.
      Parameters:
      command - The GET command that will be sent.
      Returns:
      Returns a String version of what the server sent back.
    • postMessage

      public String postMessage(String command, int postType, String pkg, int pkgIndex, boolean newStatus)
      Method that allows client to send a POST message to server.
      Parameters:
      command - POST command to be sent.
      postType - Type of Post message to be sent, helps with client logic.
      pkg - PackageBase to be sent, in String JSON format.
      pkgIndex - Index of the package in the current state's list.
      newStatus - The new delivery status of the package, false if REMOVE or ADD.
      Returns:
      Returns a String version of the updated arraylist from the server.