A simple chat
This week you will implement a simple chat. Your starting point is a simple (not-distributed) Java application. Your task is to change this to a Client/Server application. Before starting with this practical be sure that you understood the tasks you have done in practical 1.
The easy bit
- Download the Java program PrimitiveChat.java
and save it under the name PrimitiveChat.java
Copy this file to your local drive. Compile and run the file using javac and java similar to last weeks practical. Understand the behavior of the program before proceeding!
The tricky bit
Investigate the source code of PrimitiveChat.java. You will find that a procedure printText() is called. This is a local procedure call. Use XML-RPC technology for implementing a Client/Server application where this procedure is called remotely in a similar way, i.e. you type text on the client and the text is displayed on the server. Use the files from last week and the example from the lecture to get an idea how to do it.
Similarly to last week start your server, give your ip address to a friend, run a client with your friend's ip address, and chat!
Add more features, e.g.
A dialog box, where you can enter the ip-address, so that you do not need to compile the client each time, when you want to connect to a different server.
A window that pops up on the server side, to indicate that a new message has arrived.
Change Client and Server, so that you send your name together with the text. The server can then distinguish your message from other messages.
Send a message to more than one server at a time.
Back to the main page
© Marc Conrad, 2003.
The material on this page is presented "as is". There is no warranty implied by presenting this stuff.
Feel free to use and modify the material for your own teaching.
When doing so please give a reference to this web site (http://perisic.com/xmlrpc)
The webspace for this project is kindly provided by the Perisic