Yet Another Chat Client

chatClient.png

Description

The application connects to remote chat server and waits for user input. User messages are prefixed with user ID (entered in separate text field) and sent to server. Initial user ID is retrieved using System.getProperty( "user.name" ).

The message format is:

It is expected that server distributes (broadcasts) messages to all participants, so the user should receive its own message back from the server immediately.

Inbound messages are captured by the instance of ChatClient class in a separate thread ChatClient.run(). Received messages are presented to the user in JEditPane component of the ChatClientFrame GUI class. The client uses HTML to markup messages.

Chat client accepts following commands from the user:

In case of unsuccessful connection, chat client will retry three times to reconnect. After third unsuccessful reconnect, user can acknowledge mishap and quit application simply buy pressing ENTER. Alternatively, the user may enter :open command and try to (re)connect to the same or some other chat server.

One can start application with the following command:

where the default host is 127.0.0.1 and the default port is 2000

Executable

The jar file of the package can be found here.

Sources

Source files: