diff options
Diffstat (limited to 'src/network/core/address.h')
-rw-r--r-- | src/network/core/address.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/network/core/address.h b/src/network/core/address.h index af10a2756..b22bcac0e 100644 --- a/src/network/core/address.h +++ b/src/network/core/address.h @@ -12,6 +12,7 @@ #include "os_abstraction.h" #include "config.h" +#include "../../company_type.h" #include "../../string_func.h" #include "../../core/smallmap_type.hpp" @@ -177,4 +178,37 @@ public: static const std::string GetPeerName(SOCKET sock); }; +/** + * Types of server addresses we know. + * + * Sorting will prefer entries at the top of this list above ones at the bottom. + */ +enum ServerAddressType { + SERVER_ADDRESS_DIRECT, ///< Server-address is based on an hostname:port. +}; + +/** + * Address to a game server. + * + * This generalises addresses which are based on different identifiers. + */ +class ServerAddress { +private: + /** + * Create a new ServerAddress object. + * + * Please use ServerAddress::Parse() instead of calling this directly. + * + * @param type The type of the ServerAdress. + * @param connection_string The connection_string that belongs to this ServerAddress type. + */ + ServerAddress(ServerAddressType type, const std::string &connection_string) : type(type), connection_string(connection_string) {} + +public: + ServerAddressType type; ///< The type of this ServerAddress. + std::string connection_string; ///< The connection string for this ServerAddress. + + static ServerAddress Parse(const std::string &connection_string, uint16 default_port, CompanyID *company_id = nullptr); +}; + #endif /* NETWORK_CORE_ADDRESS_H */ |