Refactor ChatRoom and ChatUser classes for improved message handling and user management
- Introduced new methods in ChatRoom for processing message queues and broadcasting messages to users. - Refactored message suppression logic into a dedicated method to enhance readability and maintainability. - Updated ChatUser to streamline user initialization and database interactions, including legacy support. - Enhanced WebSocket message handling in SSLServer with clearer routing and error handling. - Added helper functions for WebSocket header management to improve code organization and clarity.
This commit is contained in:
@@ -68,6 +68,22 @@ namespace Yc
|
||||
unsigned int flags();
|
||||
Json::Value userList();
|
||||
|
||||
// Message structure for internal use
|
||||
struct Message
|
||||
{
|
||||
ChatUser::MsgType type;
|
||||
std::string messageTr;
|
||||
std::string userName;
|
||||
std::string color;
|
||||
};
|
||||
|
||||
// Refactored helper methods
|
||||
bool hasMessagesToProcess() const;
|
||||
void processMessageQueue();
|
||||
void broadcastMessageToUsers(const Message& message);
|
||||
bool shouldSuppressMessageForUser(const Message& message, std::shared_ptr<ChatUser> user) const;
|
||||
bool isDiceRoom() const;
|
||||
|
||||
// Neue Würfel-Funktionen
|
||||
bool startDiceGame(int rounds, std::shared_ptr<ChatUser> admin);
|
||||
bool rollDice(std::shared_ptr<ChatUser> user, int diceValue);
|
||||
@@ -80,13 +96,6 @@ namespace Yc
|
||||
void reloadRoomList();
|
||||
|
||||
private:
|
||||
struct Message
|
||||
{
|
||||
ChatUser::MsgType type;
|
||||
std::string messageTr;
|
||||
std::string userName;
|
||||
std::string color;
|
||||
};
|
||||
|
||||
struct DiceResult
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user