how to connect unity to master server

Hi everyone.

i’m new to unity networking.
and this is my code that “using unity test server” :

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class startServer : MonoBehaviour {
    public Transform menu;
    public HostData[] data;
    public Transform[] ButtonRoom;
    public Text[] TextNameRoom;


    public void StartServerNew (){
      
            var useNet = !Network.HavePublicAddress ();
            Network.InitializeServer (50, 25000, useNet);
            MasterServer.RegisterHost ("roomname", "tank", "unity");
      
    }
    public void Refresh(){
        MasterServer.RequestHostList ("roomname");
        data = MasterServer.PollHostList ();
        for (int i = 0; i < data.Length; i++) {
            ButtonRoom [i].gameObject.SetActive(true);
            TextNameRoom [i].text = data [i].gameName;
          
        }
    }
    public void ConnectToRoom(int NumberRoom){
        for (var i = 0; i < data.Length; i++) {
            Network.Connect (data[NumberRoom].ip, data[NumberRoom].port);
        }
    }

    void Update(){
        if (Network.peerType != NetworkPeerType.Disconnected) {
            menu.gameObject.SetActive (false);
    }
}
}

now i want to know to can i host my own server?
so i just download master server, but i have no idea how to connect unity to master server.
thanks.

I see that MasterServer is legacy code: https://docs.unity3d.com/Manual/net-MasterServer.html.

I’ll have to investigate more but I think MasterServer got replaced by MatchMaker.

I think when you call RegisterHost, it registers your IP into the MasterServer. Then a client can connect to your room. The server is hosted by the first client that starts the application if your application is coded that way.

New Master Server