> For the complete documentation index, see [llms.txt](https://redboard.gitbook.io/r-type-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://redboard.gitbook.io/r-type-1/server/room/chatmessage.md).

# ChatMessage

The ChatMessage class is a nested class inside the [Room](/r-type-1/server/room.md) 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
```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.

```cpp
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.

```cpp
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.

```cpp
u_int getPlayerId() const;
```

#### Returns

An `unsigned int` containing the player id

### getMessage

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

```cpp
const std::string &getMessage() const;
```

#### Returns

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