Does machine creating the server have to connect also?

So I am trying to get a game lobby running for my game like this:

I create a game room like this:

Network.InitializeServer(int.Parse(maxPlayers), int.Parse(port), !Network.HavePublicAddress());
MasterServer.RegisterHost(gameName, serverName);

And a client joins this lobby like this:


This works but the server initializer does not count as a player. This tells me that we have only one player connected:


And if I connect to my server the same way as my client but on my server machine, the server gets disconnected.

Do I have to make the host a connected player the same way as the client? What am I not understanding correctly?

Network.connections by nature is a list of the connections to the machine it’s called on. The server doesn’t need to be “connected” to itself, so it isn’t in the list. Conversely, if it is called on a client, the only member in the list would be the server, since that’s the only machine the client is connected to.

If you want to have a list of all the players currently in your lobby, you’re going to have to implement it yourself. Usually you do it by using

List<NetworkPlayer> listOfPlayers;

void OnPlayerConnected(NetworkPlayer player) {
   listOfPlayers.Add( player );

on the server.

When a client connects, ask the server for a list of all the clients already connected.