Exemplo n.º 1
0
    public void Start()
    {
        // Use command line port if possible, otherwise use default (hard coded port)
        string[] args = System.Environment.GetCommandLineArgs();
        for (int i = 0; i < args.Length - 1; i++)
        {
            int value = 0;
            if (args[i] != "-port")
            {
                continue;
            }

            if (!int.TryParse(args[i + 1], out value))
            {
                continue;
            }

            if (value < 1000 || value >= 65536)
            {
                continue;
            }

            port = value;
            Debug.Log(":) LISTEN PORT " + port + " FOUND ON COMMAND LINE");
            break;
        }

        string sdkVersion = GameLiftServerAPI.GetSdkVersion().Result;

        Debug.Log(":) SDK VERSION: " + sdkVersion);
        try
        {
            var initOutcome = GameLiftServerAPI.InitSDK();
            if (initOutcome.Success)
            {
                Debug.Log(":) SERVER IS IN A GAMELIFT FLEET");
                ProcessReady();
            }
            else
            {
                if (gl != null)
                {
                    gl.gameliftStatus = false;
                }
                Debug.Log(":( SERVER NOT IN A FLEET. GameLiftServerAPI.InitSDK() returned " + Environment.NewLine + initOutcome.Error.ErrorMessage);
            }
        }
        catch (Exception e)
        {
            Debug.Log(":( SERVER NOT IN A FLEET. GameLiftServerAPI.InitSDK() exception " + Environment.NewLine + e.Message);
        }
    }