Chat
This sample demonstrates a client-server chat application.
In a chat application every user connects to the moderator and can send chat messages : the moderator forwards messages to all the clients connected.
Furthermore a user may send to a specific user a private message which must be forwarded only to that user.
Model
Data
The context needs to maintain :
- the list of connected users
Orders
Orders are sent by the users :
- a chat message to everyone : the message text and the origin user
- a private chat message to a specific user : the message text, the origin user and the destination user
Results
Results are sent to the users :
- a chat message to everyone : the message text and the origin user
- a private chat message from a specific user : the message text and the origin user
Updates
Updates are context data synchronization messages sent to the users :
- a new user connects
- a connected user disconnects
Diagrams
Class diagrams
blabla Model :
blabla Controller :
blabla View :
Implementation
The modularity of the design appears clearly and drives the implementation process safely.
The complete source code for this sample can be found in the jtge.sample.chat package.