Registering a server with the Master Server
Now that you've configured the Master Server, it's time to register a server with it. This is easy to do.
Immediately after making a call to Network.InitializeServer
, make another call to MasterServer.RegisterHost
. This call connects to the Master Server and tells it to display our server in the public game list.
The
RegisterHost
function takes three parameters, all strings: gameTypeName
, gameName
, and comment
. The game type name is used to separate different game listings from each other. For example, if two games use the same Master Server, they would both supply different game type names in order to avoid getting listings for the other game. The game name is the name of the host server, for example "John's server". The comment is a general purpose data string, essentially anything can be stored here. For example you could store data about the server (such as map rotation, available modes, and so on) and display these to the user while they browse the lobby.
Because RegisterHost is a separate call from InitializeServer, you can simply omit the call to RegisterHost to implement private or LAN-style servers.
Note
You can call RegisterHost more than once while a server is running to update the information stored on the Master Server. For example, if the server changes to a new level, you might call RegisterHost again to update the lobby.