Declares host record models and utilities.
More...
#include <cstdint>
#include <string>
#include <string_view>
#include <vector>
Go to the source code of this file.
|
|
constexpr uint16_t | app::DEFAULT_HOST_PORT = 47989 |
| | Default HTTP port used by Moonlight-compatible hosts.
|
| |
Declares host record models and utilities.
◆ HostAppListState
Fetch state for the per-host app library.
| Enumerator |
|---|
| idle | No app-list request is active and no fresh result is pending.
|
| loading | An app-list request is currently in progress.
|
| ready | A recent app list is available for display.
|
| failed | The latest app-list request failed.
|
◆ HostReachability
Reachability state tracked for a discovered or saved host.
| Enumerator |
|---|
| unknown | Reachability has not been probed yet.
|
| online | The host responded to the latest reachability check.
|
| offline | The host did not respond to the latest reachability check.
|
◆ PairingState
Pairing state tracked for a saved host record.
| Enumerator |
|---|
| not_paired | The client has not completed pairing with the host.
|
| paired | The client is paired and can issue authenticated requests.
|
◆ build_default_host_display_name()
| std::string app::build_default_host_display_name |
( |
std::string_view | normalizedAddress | ) |
|
Build a controller-friendly default display name for a host.
- Parameters
-
| normalizedAddress | Canonical IPv4 address. |
- Returns
- Generated display label.
◆ contains_host_address()
| bool app::contains_host_address |
( |
const std::vector< HostRecord > & | records, |
|
|
std::string_view | normalizedAddress, |
|
|
uint16_t | port = 0 ) |
Return whether a host list already contains an endpoint.
- Parameters
-
| records | Saved hosts to search. |
| normalizedAddress | Canonical IPv4 address to match. |
| port | Stored port override to match. |
- Returns
- true when a saved host uses the same address and effective port.
◆ effective_host_port()
| uint16_t app::effective_host_port |
( |
uint16_t | port | ) |
|
Return the effective TCP port for a host record.
- Parameters
-
| port | Stored port override where zero means default. |
- Returns
- Effective host port.
◆ host_matches_endpoint()
| bool app::host_matches_endpoint |
( |
const HostRecord & | host, |
|
|
std::string_view | normalizedAddress, |
|
|
uint16_t | port ) |
Return whether a host record matches a specific endpoint.
A host matches when the canonical host address equals normalizedAddress and port matches any known effective host endpoint (stored HTTP port, resolved HTTP port, or HTTPS port).
- Parameters
-
| host | Host record to test. |
| normalizedAddress | Canonical IPv4 address to compare. |
| port | Endpoint port where zero means DEFAULT_HOST_PORT. |
- Returns
- true when the host record can be reached by the given endpoint.
◆ is_valid_ipv4_address()
| bool app::is_valid_ipv4_address |
( |
std::string_view | address | ) |
|
Return whether a string is a valid IPv4 address.
- Parameters
-
| address | Candidate IPv4 address. |
- Returns
- true when the address can be normalized.
◆ normalize_ipv4_address()
| std::string app::normalize_ipv4_address |
( |
std::string_view | address | ) |
|
Normalize a user-provided IPv4 address.
- Parameters
-
| address | Candidate IPv4 address. |
- Returns
- Canonical dotted-quad form, or an empty string when invalid.
◆ parse_host_records()
| ParseHostRecordsResult app::parse_host_records |
( |
std::string_view | serializedRecords | ) |
|
Parse host records from the stable serialized text format.
- Parameters
-
| serializedRecords | Serialized host record text. |
- Returns
- Parsed records plus any non-fatal line errors.
◆ serialize_host_records()
| std::string app::serialize_host_records |
( |
const std::vector< HostRecord > & | records | ) |
|
Serialize host records into a stable tab-separated text format.
The serialized form preserves the saved host identity plus any cached app-list entries and their local visibility or artwork metadata.
- Parameters
-
| records | Host records to serialize. |
- Returns
- Serialized text suitable for disk persistence.
◆ to_string() [1/2]
Return a stable lowercase label for a host reachability state.
- Parameters
-
| reachability | Reachability state to stringify. |
- Returns
- Stable lowercase label.
◆ to_string() [2/2]
Return a stable lowercase label for a pairing state.
- Parameters
-
| pairingState | Pairing state to stringify. |
- Returns
- Stable lowercase label.
◆ try_parse_host_port()
| bool app::try_parse_host_port |
( |
std::string_view | portText, |
|
|
uint16_t * | parsedPort ) |
Parse a user-supplied TCP port string.
- Parameters
-
| portText | Text entered by the user. |
| parsedPort | Output port override where zero means default. |
- Returns
- true when the port string is valid.
◆ validate_host_record()
| bool app::validate_host_record |
( |
const HostRecord & | record, |
|
|
std::string * | errorMessage = nullptr ) |
Validate a host record before saving or serializing it.
- Parameters
-
| record | Host record to validate. |
| errorMessage | Optional output for a validation error. |
- Returns
- true when the record is valid.