develop a simple java chat application
- chat model: Mediator design pattern
- server-client communication: TCP socket
Client:
- implement front-end with swing
- main thread: receive information from GUI, pack to message and send it to the server(Event-driven model)
- use a seperate thread to continuously receive message from the server.
- a user can be involved in mutiple chat at the same time.
Server:
- for every client connection, use a ServerThread to handle read-write on this socket.
- A client has only one connection to the server, and every ServerThread transmit messages from this client to target client or push it to the message queue of target Chat.
- every Chat use a seperate thread to continuously take messages from message queue and broadcast it to every member of this Chat (handle individual chat and group chat in the same way).
- if users list, group chats list or chat members list changes, the server will push this update to relative clients
Message:
- abstract class Message is the super class for all specific message classes
- a kind of specific message class represents a kind of message, like chat message, invitation message, join group message and so on.
Individual chat:
- a user can send an invition to another user. If the other accepts it, then the individual chat is built and they can chat.
Group Chat:
- a user can create groups
- any client can join any group without permission check
Additional functions:
- support files upload and download