| | |
| | |
| | |
| |
|
| | #pragma once |
| |
|
| | #include <array> |
| | #include <memory> |
| | #include <string> |
| | #include <vector> |
| | #include "common/common_types.h" |
| | #include "network/verify_user.h" |
| |
|
| | namespace Network { |
| |
|
| | constexpr u32 network_version = 4; |
| |
|
| | constexpr u16 DefaultRoomPort = 24872; |
| |
|
| | constexpr u32 MaxMessageSize = 500; |
| |
|
| | |
| | static constexpr u32 MaxConcurrentConnections = 254; |
| |
|
| | constexpr std::size_t NumChannels = 1; |
| |
|
| | struct RoomInformation { |
| | std::string name; |
| | std::string description; |
| | u32 member_slots; |
| | u16 port; |
| | std::string preferred_game; |
| | u64 preferred_game_id; |
| | std::string host_username; |
| | bool enable_citra_mods; |
| | }; |
| |
|
| | struct GameInfo { |
| | std::string name{""}; |
| | u64 id{0}; |
| | }; |
| |
|
| | using MacAddress = std::array<u8, 6>; |
| | |
| | |
| | constexpr MacAddress NoPreferredMac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; |
| |
|
| | |
| | constexpr MacAddress BroadcastMac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; |
| |
|
| | |
| | enum RoomMessageTypes : u8 { |
| | IdJoinRequest = 1, |
| | IdJoinSuccess, |
| | IdRoomInformation, |
| | IdSetGameInfo, |
| | IdWifiPacket, |
| | IdChatMessage, |
| | IdNameCollision, |
| | IdMacCollision, |
| | IdVersionMismatch, |
| | IdWrongPassword, |
| | IdCloseRoom, |
| | IdRoomIsFull, |
| | IdConsoleIdCollision, |
| | IdStatusMessage, |
| | IdHostKicked, |
| | IdHostBanned, |
| | |
| | IdModKick, |
| | IdModBan, |
| | IdModUnban, |
| | IdModGetBanList, |
| | |
| | IdModBanListResponse, |
| | IdModPermissionDenied, |
| | IdModNoSuchUser, |
| | IdJoinSuccessAsMod, |
| | }; |
| |
|
| | |
| | enum StatusMessageTypes : u8 { |
| | IdMemberJoin = 1, |
| | IdMemberLeave, |
| | IdMemberKicked, |
| | IdMemberBanned, |
| | IdAddressUnbanned, |
| | }; |
| |
|
| | |
| | class Room final { |
| | public: |
| | enum class State : u8 { |
| | Open, |
| | Closed, |
| | }; |
| |
|
| | struct Member { |
| | std::string nickname; |
| | std::string username; |
| | std::string display_name; |
| | std::string avatar_url; |
| | GameInfo game_info; |
| | MacAddress mac_address; |
| | }; |
| |
|
| | Room(); |
| | ~Room(); |
| |
|
| | |
| | |
| | |
| | State GetState() const; |
| |
|
| | |
| | |
| | |
| | const RoomInformation& GetRoomInformation() const; |
| |
|
| | |
| | |
| | |
| | std::string GetVerifyUID() const; |
| |
|
| | |
| | |
| | |
| | std::vector<Member> GetRoomMemberList() const; |
| |
|
| | |
| | |
| | |
| | bool HasPassword() const; |
| |
|
| | using UsernameBanList = std::vector<std::string>; |
| | using IPBanList = std::vector<std::string>; |
| |
|
| | using BanList = std::pair<UsernameBanList, IPBanList>; |
| |
|
| | |
| | |
| | |
| | |
| | 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& host_username = "", const std::string& preferred_game = "", |
| | u64 preferred_game_id = 0, |
| | std::unique_ptr<VerifyUser::Backend> verify_backend = nullptr, |
| | const BanList& ban_list = {}, bool enable_citra_mods = false); |
| |
|
| | |
| | |
| | |
| | void SetVerifyUID(const std::string& uid); |
| |
|
| | |
| | |
| | |
| | BanList GetBanList() const; |
| |
|
| | |
| | |
| | |
| | void Destroy(); |
| |
|
| | private: |
| | class RoomImpl; |
| | std::unique_ptr<RoomImpl> room_impl; |
| | }; |
| |
|
| | } |
| |
|