Add Support for Room Descriptions
This commit is contained in:
parent
c396e3c6e5
commit
5f0e189238
16 changed files with 110 additions and 23 deletions
|
@ -124,6 +124,7 @@ public:
|
|||
* The packet has the structure:
|
||||
* <MessageID>ID_ROOM_INFORMATION
|
||||
* <String> room_name
|
||||
* <String> room_description
|
||||
* <u32> member_slots: The max number of clients allowed in this room
|
||||
* <String> uid
|
||||
* <u16> port
|
||||
|
@ -404,6 +405,7 @@ void Room::RoomImpl::BroadcastRoomInformation() {
|
|||
Packet packet;
|
||||
packet << static_cast<u8>(IdRoomInformation);
|
||||
packet << room_information.name;
|
||||
packet << room_information.description;
|
||||
packet << room_information.member_slots;
|
||||
packet << room_information.uid;
|
||||
packet << room_information.port;
|
||||
|
@ -584,9 +586,10 @@ Room::Room() : room_impl{std::make_unique<RoomImpl>()} {}
|
|||
|
||||
Room::~Room() = default;
|
||||
|
||||
bool Room::Create(const std::string& name, const std::string& server_address, u16 server_port,
|
||||
const std::string& password, const u32 max_connections,
|
||||
const std::string& preferred_game, u64 preferred_game_id) {
|
||||
bool Room::Create(const std::string& name, const std::string& description,
|
||||
const std::string& server_address, u16 server_port, const std::string& password,
|
||||
const u32 max_connections, const std::string& preferred_game,
|
||||
u64 preferred_game_id) {
|
||||
ENetAddress address;
|
||||
address.host = ENET_HOST_ANY;
|
||||
if (!server_address.empty()) {
|
||||
|
@ -603,6 +606,7 @@ bool Room::Create(const std::string& name, const std::string& server_address, u1
|
|||
room_impl->state = State::Open;
|
||||
|
||||
room_impl->room_information.name = name;
|
||||
room_impl->room_information.description = description;
|
||||
room_impl->room_information.member_slots = max_connections;
|
||||
room_impl->room_information.port = server_port;
|
||||
room_impl->room_information.preferred_game = preferred_game;
|
||||
|
|
|
@ -25,6 +25,7 @@ constexpr std::size_t NumChannels = 1; // Number of channels used for the connec
|
|||
|
||||
struct RoomInformation {
|
||||
std::string name; ///< Name of the server
|
||||
std::string description; ///< Server description
|
||||
u32 member_slots; ///< Maximum number of members in this room
|
||||
std::string uid; ///< The unique ID of the room
|
||||
u16 port; ///< The port of this room
|
||||
|
@ -103,8 +104,9 @@ public:
|
|||
* Creates the socket for this room. Will bind to default address if
|
||||
* server is empty string.
|
||||
*/
|
||||
bool Create(const std::string& name, const std::string& server = "",
|
||||
u16 server_port = DefaultRoomPort, const std::string& password = "",
|
||||
bool Create(const std::string& name, const std::string& description = "",
|
||||
const std::string& server = "", u16 server_port = DefaultRoomPort,
|
||||
const std::string& password = "",
|
||||
const u32 max_connections = MaxConcurrentConnections,
|
||||
const std::string& preferred_game = "", u64 preferred_game_id = 0);
|
||||
|
||||
|
|
|
@ -230,11 +230,13 @@ void RoomMember::RoomMemberImpl::HandleRoomInformationPacket(const ENetEvent* ev
|
|||
|
||||
RoomInformation info{};
|
||||
packet >> info.name;
|
||||
packet >> info.description;
|
||||
packet >> info.member_slots;
|
||||
packet >> info.uid;
|
||||
packet >> info.port;
|
||||
packet >> info.preferred_game;
|
||||
room_information.name = info.name;
|
||||
room_information.description = info.description;
|
||||
room_information.member_slots = info.member_slots;
|
||||
room_information.port = info.port;
|
||||
room_information.preferred_game = info.preferred_game;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue