ServerAddress - jimdroberts/FishMMO GitHub Wiki
Serializable class and struct for representing server addresses in FishMMO. ServerAddresses
holds a list of available server addresses for server selection, while ServerAddress
represents an individual server's IP and port, and provides a method to format the address as an HTTPS URL.
-
public List Addresses
List of available server addresses (ServerAddresses only).
-
public string Address
IP address or hostname of the server (ServerAddress only).
-
public ushort Port
Port number for the server (ServerAddress only).
-
public string HTTPSAddress()
Returns the server address formatted as an HTTPS URL, ensuring proper prefix and trailing slash. Returns: Formatted HTTPS URL for the server address.
- Create a
ServerAddresses
instance and populate itsAddresses
list withServerAddress
structs. - Use the
HTTPSAddress()
method to get a properly formatted HTTPS URL for each server address.
// Example 1: Creating and formatting server addresses
ServerAddresses servers = new ServerAddresses {
Addresses = new List<ServerAddress> {
new ServerAddress { Address = "patcher.fishmmo.com", Port = 443 },
new ServerAddress { Address = "backup.fishmmo.com", Port = 443 }
}
};
string url = servers.Addresses[0].HTTPSAddress();
// url == "https://patcher.fishmmo.com:443/"
- Always use the
HTTPSAddress()
method to ensure URLs are correctly formatted for secure connections. - Populate the
Addresses
list with all available servers to provide redundancy and load balancing. - Validate IP addresses and ports before adding them to the list to avoid connection issues.