Added missing parts in libnetwork (#2838)

* Network: Set and send the game information over enet

Added Callbacks for RoomMember and GetMemberList to Room in preparation for web_services.
This commit is contained in:
B3n30 2017-08-19 19:14:33 +02:00 committed by James Rowe
parent 21204ba488
commit 5d0a1e7efd
9 changed files with 310 additions and 37 deletions

View file

@ -7,6 +7,7 @@
#include <array>
#include <memory>
#include <string>
#include <vector>
#include "common/common_types.h"
namespace Network {
@ -21,6 +22,11 @@ struct RoomInformation {
u32 member_slots; ///< Maximum number of members in this room
};
struct GameInfo {
std::string name{""};
u64 id{0};
};
using MacAddress = std::array<u8, 6>;
/// A special MAC address that tells the room we're joining to assign us a MAC address
/// automatically.
@ -34,7 +40,7 @@ enum RoomMessageTypes : u8 {
IdJoinRequest = 1,
IdJoinSuccess,
IdRoomInformation,
IdSetGameName,
IdSetGameInfo,
IdWifiPacket,
IdChatMessage,
IdNameCollision,
@ -51,6 +57,12 @@ public:
Closed, ///< The room is not opened and can not accept connections.
};
struct Member {
std::string nickname; ///< The nickname of the member.
GameInfo game_info; ///< The current game of the member
MacAddress mac_address; ///< The assigned mac address of the member.
};
Room();
~Room();
@ -64,6 +76,11 @@ public:
*/
const RoomInformation& GetRoomInformation() const;
/**
* Gets a list of the mbmers connected to the room.
*/
std::vector<Member> GetRoomMemberList() const;
/**
* Creates the socket for this room. Will bind to default address if
* server is empty string.