/// <summary>
        /// Registers the game server with the specified information in the master server.
        /// </summary>
        /// <param name="connection">Network connection of the game server to register.</param>
        /// <param name="msg">The network message containing the information of the game server to register.</param>
        protected virtual void RegisterGameServer(NetworkConnection connection, RegisterGameServerMessage msg)
        {
            var gameServer = new RegisteredGameServer();

            gameServer.connection   = connection;
            gameServer.id           = gameServerId++;
            gameServer.ip           = msg.ip;
            gameServer.port         = msg.port;
            gameServer.name         = msg.name;
            gameServer.maxPlayers   = msg.maxPlayers;
            gameServer.password     = msg.password;
            gameServer.hideWhenFull = msg.hideWhenFull;
            gameServer.properties   = new List <Property>(msg.properties);
            registeredGameServers.Add(gameServer);
            Debug.Log("Registered game server (id = " + gameServer.id + ") with IP address = " + gameServer.ip + " and port = " + gameServer.port + ".");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Registers this game server in the master server.
        /// </summary>
        protected virtual void RegisterInMasterServer()
        {
            gameToMaster = new NetworkClient();
            gameToMaster.RegisterHandler(MsgType.Connect, netMsg =>
            {
                var msg          = new RegisterGameServerMessage();
                msg.ip           = gameServerIp;
                msg.port         = gameServerPort;
                msg.name         = gameName;
                msg.maxPlayers   = maxPlayers;
                msg.password     = password;
                msg.hideWhenFull = hideWhenFull;
                msg.properties   = properties.ToArray();
                gameToMaster.Send(GameRoomsNetworkProtocol.RegisterGameServer, msg);

                NotifyGameServerIsReady();
            });
            gameToMaster.Connect(masterServerIp, masterServerPort);
        }