Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write the following program in Java : Design and Implement a Simple Chat Room Program Based on C/S Structure of Character Interface The program is

write the following program in Java:

Design and Implement a Simple Chat Room Program Based on C/S Structure of Character Interface

The program is divided into two parts: server side and client side:

Server function requirements:

1. At startup, a user file is read in first. All user names and passwords (at least 10) are saved in the user file (in clear text, but not in the real system). Then a prompt is displayed, waiting for the command to be entered. The acceptable commands include list: list all online users; Listall: lists all users; Quit: exit the system;

2. Listen on the fixed port (above 8000) and wait for the client connection;

3. After the client connects successfully, there is a process to verify the user name and password. If the user name and password are correct, send a prompt message to the client for successful verification; otherwise, send a user name or password error message to the client and wait for the user to verify again until the verification is successful or the client is disconnected;

4. At least 5 clients can chat at the same time;

5. Forward the chat information sent by the client and support anonymous chat;

6. Log function. Use a text file to record each user's behavior. These behaviors include each successful login information (including IP address and time), each failed login information (including IP address and time), and each time you exit the chat room.

Client function requirements:

1. After startup, connect to the server first;

2. After the connection is successful, the user is prompted to enter the user name and password, and the user name and password entered by the user are sent to the server for verification. After the verification is successful, the user will enter the chat room successfully, otherwise, the user will be prompted to re-enter the user name and password until the verification is successful or the user ends the program;

3. After successful verification, you can enter the chat room with a prompt;

4. The chat room shall be able to display the non private chat information of all users and the private chat information for themselves;

5. In the chat room, users can enter three types of strings: ordinary strings, which are broadcast chat messages that can be seen by everyone; The string starting with @+user name is private chat information, which can only be seen by the user who arrives at @; @@+ Command is a system command;

6. The system commands are: list: list the current online users; Quit: exit the system; Showanonymous: displays whether the current chat mode is anonymous; anonymous: switch between anonymous chat and real name chat.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

More Books

Students also viewed these Databases questions

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago