A. A GUI Controller – this will have instructions, and buttons to start the server, to start each client, and to exit.
B. Client – The Chat application for each user. Each client will run in its own thread. Start this class after the Server is running.
C. Server – Manages the clients, checking their screen names and echo-printing their messages to the other clients. Start this class before the client.
Step1
Operation (what the user sees):
When the application starts, the user is presented with a window that has a list of instructions and three buttons: “Start Server”, “Start Client”, and “Exit”.
The user starts the server first. If they attempt to start a client before a server, or to start more than one server, an error message is given.
Then the user starts a client. The user is asked for a screen name. If the name is already in use in this session an error message is given the user is re-asked for a screen name, or if the user selects “Cancel”, the user is re-asked for a screen name. The user can start multiple clients.
When a user successfully enters a screen name, a window is shown where the user can type in a message. When the user enters a message, it is rebroadcast to all users.
Specifications (what the programmer does):
1) Create a GUI Controller: this will have instructions, and buttons to start the server, to start each client, and to exit.
a) Instructions will be several labels
b) Start Server Button:
i) This button will have a mnemonic and a tooltip.
ii) When this button is selected, create a new ChatServerExec.
iii) Then call the ChatServerExec.startServer method with the port number as an argument if the server has not yet been created.
iv) The GUI controller will maintain a sentinel that specifies whether or not the server has been started yet, and display a JOptionPane message if it has.
c) Start Client Button:
i) This button will have a mnemonic and a tooltip.
ii) Each time the “Start Client” button is selected in the GUI, create a new ChatClientExec.
iii) Then call the ChatClientExec.startClient method with the port number as an argument
d) Exit Button:
i) This button will have a mnemonic and a tooltip.
ii) When selected, the server and any clients, along with the controller GUI, will close.
2) Client – The Chat application for each user. The client will consist of an executive (ChatClientExec) and ChatClient classes.
a) Start ChatClientExec from the GUI after the Server is running.
b) ChatClientExec will create a new ChatClient and run it in its own thread.
c) The ChatClient process will create a new Stage, which will produce a separate GUI for each client.
d) The user will be asked to enter a screen name
e) When the screen name is accepted, the client’s chat textbox will be enabled. When the user types into the textbox, the client will transmit the message to the server.
f) When the client receives messages from the server, it will be displayed in the client’s textarea.
3) Server – Manages the clients.
a) Maintain a list of screen names in use in this session and check new names for duplication.
b) Maintain a list of PrintWriter objects, and iterate through them to echo-print clients’ messages.
c) Start this class before the client.
4) Assumptions:
a) It is assumed that the GUI, the server, and clients will be run on the same computer.
b) It is assumed that synchronization of objects with locks or conditions will not be needed.
5) Application Protocol. The Chat Protocol is as follows. (Bold font indicates strings sent between server and clients)
Condition Server Action Client Action Client starts, server accepts client Sends “SUBMITNAME” Receives “SUBMITNAME” and asks user for screen name Client has received “SUBMITNAME” Server blocks waiting for input Client sends screen name Client has sent screen name Receives client screen name, checks for duplicates, sends “NAMEACCEPTED" Client blocks waiting for input Server has sent “NAMEACCEPTED" Server blocks waiting for input Receives “NAMEACCEPTED", sets message text field to “editable” Client has received “NAMEACCEPTED" Server blocks waiting for input Client types a message in text field, sends message Client has sent message Receives client message, sends “MESSAGE name: message" to all clients Client blocks waiting for input Server has sent message to all clients Server blocks waiting for input Client receives “MESSAGE name: message" and prints to text area.
Deliverables:
Java files - The src folder with your client and server and test (.java) files
Javadoc files - The doc folder with your javadoc for student generated files
UML Class Diagram (an image, not the proprietary format, must be a .jpg or .pdf)
Deliverable format: The above deliverables will be packaged as follows. Two compressed files in the following formats:
LastNameFirstName_AssignmentX_Complete.zip [a compressed file containing the
following]
UML.jpg
Assignment 7 Checklist (filled in with YES or NO or ?)
doc [a directory] please include the entire doc folder
generated files
file1.html (example)
file2.html (example)
src [a directory] contains your client and server (.java) files. Include all
files that are needed to run your assignment, including those given to you
File1.java (example)
File2.java (example)
File_Test.java (example)
LastNameFirstName_AssignmentX_Moss.zip [a compressed file containing only the
following]
contains .java file which includes student generated client and server (.java) files – NO FOLDERS!!