Пример #1
0
        public HFTRuntimeOptions(HFTGameOptions userOptions)
        {
            name = String.IsNullOrEmpty(userOptions.name) ? Application.productName : userOptions.name;

            id = userOptions.id;
            // gameId = String.IsNullOrEmpty(Application.productName) ? "HFTUnityUnnamed" : HFTUtil.SafeName(Application.productName);
            // This currently has to be HFTUnity because the controller doesn't know what gameId to use
            // We could send it with "?gameId=" but does it really matter?
            gameId             = "HFTUnity";
            serverPort         = String.IsNullOrEmpty(userOptions.serverPort) ? "18679" : userOptions.serverPort;
            rendezvousUrl      = userOptions.rendezvousUrl;
            master             = userOptions.master;
            url                = userOptions.url;
            dns                = userOptions.dns;
            captivePortal      = userOptions.captivePortal;
            showMessages       = HFTHappyFunTimesSettings.showMessages;
            debug              = HFTHappyFunTimesSettings.debug;
            ipv4DnsAddress     = userOptions.ipv4DnsAddress;
            ipv6DnsAddress     = userOptions.ipv6DnsAddress;
            controllerFilename = userOptions.controllerFilename;
            if (String.IsNullOrEmpty(controllerFilename))
            {
                controllerFilename = "controller.html";
            }
            controllerFilename = controllerFilename.Replace("\\", "/");

            HFTArgs args = new HFTArgs();

            args.installationMode.GetIfSet(ref installationMode);
            args.master.GetIfSet(ref master);
            args.showMessages.GetIfSet(ref showMessages);
            args.debug.GetIfSet(ref debug);

            args.url.GetIfSet(ref url);
            args.id.GetIfSet(ref id);
            args.rendezvousUrl.GetIfSet(ref rendezvousUrl);
            args.serverPort.GetIfSet(ref serverPort);
            args.ipv4DnsAddress.GetIfSet(ref ipv4DnsAddress);
            args.ipv6DnsAddress.GetIfSet(ref ipv6DnsAddress);

            if (HFTHappyFunTimesSettings.installationMode)
            {
                installationMode = true;
            }

            if (String.IsNullOrEmpty(url))
            {
                url         = "ws://localhost:" + serverPort;
                startServer = true;
            }
            else
            {
                startServer = false;
            }

            #if UNITY_STANDALONE_OSX
            // We only provide an external server for OSX at the moment
            // That's because AFAIK on Windows we can get ports 80 and 53 without admin
            // (might be prompted for network access)
            // In Linux people can run with sudo (or submit a PR for a better way)
            // On OSX we don't want to run as sudo because it makes root own unity's logs
            if (dns || installationMode)
            {
                startExternalServer = true;
            }
            if (startExternalServer)
            {
                // is there any reason this wouldn't be true?
                // You're running as slave. Then you're not starting a server
                // You're running as master. You may or may not be starting a server
                sendFilesToServer = true;
            }
            #endif
        }
        public HFTRuntimeOptions(HFTGameOptions userOptions)
        {
            name = String.IsNullOrEmpty(userOptions.name) ? Application.productName : userOptions.name;

            id = userOptions.id;
            serverPort = userOptions.serverPort;
            rendezvousUrl = userOptions.rendezvousUrl;
            master = userOptions.master;
            url = userOptions.url;
            dns = userOptions.dns;
            captivePortal = userOptions.captivePortal;
            showMessages = HFTHappyFunTimesSettings.showMessages;
            debug = HFTHappyFunTimesSettings.debug;
            ipv4DnsAddress = userOptions.ipv4DnsAddress;
            ipv6DnsAddress = userOptions.ipv6DnsAddress;
            controllerFilename = userOptions.controllerFilename;
            if (String.IsNullOrEmpty(controllerFilename))
            {
                controllerFilename = "controller.html";
            }
            controllerFilename = controllerFilename.Replace("\\", "/");

            HFTArgs args = new HFTArgs();

            args.installationMode.GetIfSet(ref installationMode);
            args.master.GetIfSet(ref master);
            args.showMessages.GetIfSet(ref showMessages);
            args.debug.GetIfSet(ref debug);

            args.url.GetIfSet(ref url);
            args.id.GetIfSet(ref id);
            args.rendezvousUrl.GetIfSet(ref rendezvousUrl);
            args.serverPort.GetIfSet(ref serverPort);
            args.ipv4DnsAddress.GetIfSet(ref ipv4DnsAddress);
            args.ipv6DnsAddress.GetIfSet(ref ipv6DnsAddress);

            if (String.IsNullOrEmpty(url))
            {
                url = "ws://localhost:18679";
                startServer = true;
            } else {
                startServer = false;
            }

            #if UNITY_STANDALONE_OSX
                // We only provide an external server for OSX at the moment
                // That's because AFAIK on Windows we can get ports 80 and 53 without admin
                // (might be prompted for network access)
                // In Linux people can run with sudo (or submit a PR for a better way)
                // On OSX we don't want to run as sudo because it makes root own unity's logs
                if (dns || installationMode)
                {
                    startExternalServer = true;
                }
                if (startExternalServer)
                {
                    // is there any reason this wouldn't be true?
                    // You're running as slave. Then you're not starting a server
                    // You're running as master. You may or may not be starting a server
                    sendFilesToServer = true;
                }
            #endif
        }