Package io.github.astrapi69.design.pattern.observer.chat


package io.github.astrapi69.design.pattern.observer.chat
Provides classes and interfaces for implementing a chat application using the observer design pattern

The chat package includes implementations of chat rooms, users, and messages, all of which interact through the observer pattern This package demonstrates how to structure a chat system where users can send and receive messages, and how those messages are propagated to all participants in the chat room.

The key components of this package include:

  • ChatRoom - Represents a chat room where users can exchange messages
  • ChatRoomUser - Represents a user participating in a chat room
  • Message - An interface for messages sent within the chat room
  • StringMessage - A concrete implementation of Message for text-based messages
  • User - Represents a user entity in the chat system

The observer design pattern allows the chat application to notify all users in a chat room when a new message is received This package demonstrates a flexible and extensible way to implement such functionality using Java.

  • Class
    Description
    The class ChatMessage represents a message in a chat application It implements the Message interface and is serializable
    ChatRoom<M extends Message<?>>
    The class ChatRoom represents a chat room where users can send and receive messages It extends AbstractSubject and implements Subject, Room, and Serializable
    ChatRoomService<M extends Message<?>>
    The class ChatRoomService manages the creation and retrieval of chat rooms It provides a way to obtain a ChatRoom based on an observable message and a room name
    ChatRoomUser<M extends Message<?>>
    The class ChatRoomUser represents a user in a chat room who can send and receive messages This class implements Observer to observe messages in the chat room, ActionCommand to define actions when a message is received, and Serializable for serialization support
    Invitation<M extends Message<?>>
    The Interface Invitation represents an invitation to join a chat room It defines the methods to retrieve the sender, recipient, and the room associated with the invitation, as well as methods to check if the invitation has been accepted and if the denial is visible to the sender
    The interface IUser represents a user in a chat application It provides methods to manage the user's identity, including getting and setting the application user, retrieving the user's unique identifier, and obtaining the user's name
    The interface Message represents a message that can be sent in a chat application It provides methods for getting and setting the value of the message
    The class MessageRoomModelBean represents a model for a message in a chat room It includes details such as the chat room name, the user who sent the message, the message content, and any associated data, as well as the date the message was created
    Room<M extends Message<?>>
    The interface Room represents a chat room in which users can participate It provides methods to retrieve the list of users in the chat room, the history of messages sent in the room, and to check whether the room is secure
    The class StringMessage represents a message that contains a string value It implements the Message interface and provides methods to get and set the string value
    The class User represents a user in a chat application It implements the IUser interface and provides methods to manage the user's identity, including their name and ID