An applet for two-way chatting

This applet supports two-way chatting between users. It implements a client for the ConnectionBroker server, which can set up a relayed connection between a pair of such clients. There are really two functions: The user can register with the server as a client who is willing to accept a connection, or the user can make a connection with one of the clients who is waiting on the server. The applet retrieves and displays a list of waiting clients when it starts. There is a Refresh button that the user can click to refresh this list (since the list of waiting clients can change from time to time).

The user connects with one of the clients on the list by clicking it and then clicking a Connect button. Finally, there is a register button that will add the user to the list and then wait for a connection. There is an input box where the user can enter a name or other information to be displayed in other users’ client lists. The use can be a party to multiple connections simultaneously. A separater window opens for each connection that can be used to send and retrieve messages. (Note that there is nothing to stop a user from chatting with him or herself.)

An applet parameter named “server” can be used to specify the name or IP number of the server computer. If none is specified, the computer from which the applet was loaded is used. Another applet parameter, named “port”, can be used to specify the port on which the server is listening. If none is specified, then the port given by the constant DEFAULT_PORT is used. This class can also be run as a standalone application. In that case, the server must be specified as the first command-line parameter. The port, if differnent from the DEFAULT_PORT, can be specified as the second parameter.

Leave a Reply