ServerAddress - jimdroberts/FishMMO GitHub Wiki

Description

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.


API Access

Fields

  • 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).

Methods

  • 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.


Basic Usage

Setup

  1. Create a ServerAddresses instance and populate its Addresses list with ServerAddress structs.
  2. Use the HTTPSAddress() method to get a properly formatted HTTPS URL for each server address.

Example

// 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/"

Best Practices

  • 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.
⚠️ **GitHub.com Fallback** ⚠️