Libnetwork: add password protected rooms, guid, and error fixes (#3068)

* Network: Add password protected roomsand GUID

* Limit chat message size
This commit is contained in:
B3n30 2017-11-19 19:52:37 +01:00 committed by GitHub
parent 4071da5012
commit c0a7afaa5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 139 additions and 33 deletions

View file

@ -14,12 +14,22 @@ namespace Network {
constexpr u32 network_version = 1; ///< The version of this Room and RoomMember
constexpr u16 DefaultRoomPort = 1234;
constexpr u16 DefaultRoomPort = 24872;
constexpr u32 MaxMessageSize = 500;
/// Maximum number of concurrent connections allowed to this room.
static constexpr u32 MaxConcurrentConnections = 254;
constexpr size_t NumChannels = 1; // Number of channels used for the connection
struct RoomInformation {
std::string name; ///< Name of the server
u32 member_slots; ///< Maximum number of members in this room
std::string name; ///< Name of the server
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
std::string preferred_game; ///< Game to advertise that you want to play
u64 preferred_game_id; ///< Title ID for the advertised game
};
struct GameInfo {
@ -46,6 +56,7 @@ enum RoomMessageTypes : u8 {
IdNameCollision,
IdMacCollision,
IdVersionMismatch,
IdWrongPassword,
IdCloseRoom
};
@ -81,12 +92,19 @@ public:
*/
std::vector<Member> GetRoomMemberList() const;
/**
* Checks if the room is password protected
*/
bool HasPassword() const;
/**
* Creates the socket for this room. Will bind to default address if
* server is empty string.
*/
void Create(const std::string& name, const std::string& server = "",
u16 server_port = DefaultRoomPort);
bool Create(const std::string& name, 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);
/**
* Destroys the socket