Chris Pollett >
Old Classes >
CS151

   ( Print View )

Your Grade: Course Info: Homework Assignments: Practice Exams:
                            












HW #6 Page

HW#6 --- last modified January 16 2019 00:35:13..

A solution set is posted here.

Due date: Dec. 5.
========= 

Files to be submitted: cs151sec3hw6file1.jar 
====================== Your program will be compiled by
                       javac Server.java
                       rmic -v1.2 Server.java
                       javac Client.java
                       rmic -v1.2 Client
                       Then the rmiregistry will be started
                       and the server and various
                       clients started with different chat names
                       and parties.

Purpose: To gain familiarity with the proxy pattern, threads, socket based
======== programming, and rmi. 

Specification:
==============
For this homework you will write a tool to allow users to
discuss text documents in a chat-room like environment over the internet.
You can test your programs using the URL: localhost.
The Client for this assignment is an application extending JFrame
looking something like:



           ______________________
Chat Name: |____________________|

            ______________________
Chat Party: |____________________|

            ______________________
Server URL: |____________________| 
            
Text Document:
______________________
|                    |
|                    |
|                    |
|____________________|               

Chat Text:
______________________
|                    |
|                    |
|                    |
|____________________|

                  ______________________
Chat Input Line:  |____________________|                

[Connect] [Set Text] [Disconnect]

Here [] are being used to represent JButton's and the rectangular areas
are supposed to be JTextArea's if multi-lined and JTextField's otherwise. 
The idea is after the user fills out the first three JTextfield's
and clicks [Connect], a connection to the server at the given URL is
established. Clicking [Disconnect] will disconnect from this server. 
This Server implements the interface TextServer which extends Remote.
The TextServer interface has the method 
public void setText(String s, String chatParty).
Clicking on [Set Text] opens a JFileChooser which is used to open and 
read in a text document into a String. Then the setText method of the Server
is remotely called with this String and the client's chatParty.
(I know this scheme is open to hacking but let's keep things simple). 
This method then calls the  
public void textUpdate(String s) 
method for each Client in the Chat Party. The Client class implements 
TextPushClient which extends Remote. When textUpdate is called it sets the 
text in the Text Document JTextArea to the String passed. This part of the
program is similar to the RMI Stock Quote push server client example in the 
book. When the Client connects to a Server, socket based communication between
the Client and Server is established. When the user writes a line text into 
the Chat Input Line and hits return, this line is written to the server 
through this connection. The server then writes this line prefixed with the 
client's chat name and a colon to all client's in the same chat party. This 
is similar to the echo server example in the book.

Point Breakdown
===============
Departmental Coding guidelines 
     followed.........................1pt
Client GUI's show up and are as 
     described........................1pt
[Connect] button establishes a 
     socket connection with server and
     [Disconnect] closes this
     connection.......................1pt
Chat Input Line JTextField's 
     ActionListener transmits line
     to server and [Set Text] button
     works as described...............1pt
Server broadcasts client transmission
     to each other client in the same
     chat party.......................1pt
Client Chat Text areas updated by
     these broadcasts.................1pt
Server rebind's a name for itself into
     RMI registry (name should be
     consistent with what client's
     append to URL)...................1pt
Server's setText method and Client's
     textUpdate method's work as
     described and can be invoked
     remotely.........................1pt
Total.................................8pts                          

A solution set is posted here.