ChatMessage

The ChatMessage class is a nested class inside the Room class. It represents messages that was sent by players in the matchmaking lobby. Each ChatMessages is assigned to a player and contains a string. The ChatMessage object cannot be copied or moved.

Public member functions

```cpp
// Construct a new Chat Message object
ChatMessage(Room &room, u_int playerId, const std::string &message);
// Get the Time Stamp object
const std::chrono::system_clock::time_point &getTimeStamp() const;
// Get the Player Id object
u_int getPlayerId() const;
// Get the Message object
const std::string &getMessage() const;
```

Member functions documentation

Constructor

The constructor of the ChatMessage class.

ChatMessage(Room &room, u_int playerId, const std::string &message);

Parameters

  • room: A reference to the room where the chat message has been sent.

  • playerId: The id of the player that sent this message.

  • message: The string containing the message that has been sent.

getTimeStamp

Returns the time when the message has been sent.

const std::chrono::system_clock::time_point &getTimeStamp() const;

Returns

A std::chrono::system_clock::time_point const reference that stores the time.

getPlayerId

Returns the id of the player that sent this message.

u_int getPlayerId() const;

Returns

An unsigned int containing the player id

getMessage

Returns a string containing the chat message that has been sent.

const std::string &getMessage() const;

Returns

A std::string const reference that stores the message.

Last updated