Class ServerConnection
java.lang.Object
cmpt213.assignment4.packagedeliveries.client.control.ServerConnection
This class establishes connection to the server and has methods to
handle requests.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetMessage(String command) Method that allows client to sent GET messages to the server.postMessage(String command, int postType, String pkg, int pkgIndex, boolean newStatus) Method that allows client to send a POST message to server.
-
Field Details
-
GET
- See Also:
-
POST
- See Also:
-
-
Constructor Details
-
ServerConnection
public ServerConnection()Constructor for this class. On constructor call starts connection with server.
-
-
Method Details
-
getMessage
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.
-