Beispiel #1
0
 public void StartHttpServices()
 {
     MarquesasHttpServerInstance.RunningServer.port        = PluginAppSettings.GetBoolean("PortEnabled") ? PluginAppSettings.GetInt("Port") : -1;
     MarquesasHttpServerInstance.RunningServer.secure_port = PluginAppSettings.GetBoolean("SecurePortEnabled") ? PluginAppSettings.GetInt("SecurePort") : -1;
     MarquesasHttpServerInstance.RunningServer.Initialize();
     MarquesasHttpServerInstance.RunningServer.WarnIfPortsAreNotAvailable();
     MarquesasHttpServerInstance.RunningServer.Start();
     MarquesasHttpServerInstance.RunningServer.FirstTimeRunCheck();
 }
Beispiel #2
0
        private static void SelectedGameMethods(HttpProcessor oHttpProcessor)
        {
            string sJSONResponse = string.Empty;
            string sMethodName   = oHttpProcessor.pathParts[1].ToLower();

            if (!PluginAppSettings.GetBoolean("WriteEnabled") && !sMethodName.ToLower().StartsWith("get"))
            {
                oHttpProcessor.writeFailure("Marquesas Server in Read Only Mode.");
                return;
            }

            string[] oBooleans  = { "true", "false", "1", "0", "yes", "no" };
            string   sParamater = string.Empty;

            if (oHttpProcessor.pathParts.Length > 2)
            {
                sParamater = oHttpProcessor.pathParts[2].ToLower();
            }

            MethodInfo[] oGameMethods = typeof(IGame).GetMethods();
            foreach (MethodInfo oMethod in oGameMethods)
            {
                if (oMethod.Name.ToLower() == sMethodName)
                {
                    if (sParamater == String.Empty && oMethod.GetParameters().Length == 0)
                    {
                        sJSONResponse = JsonSerializer.Serialize(oMethod.Invoke(PluginHelper.StateManager.GetAllSelectedGames()[0], new object[] { }));
                        break;
                    }
                    else if (sParamater != String.Empty && oMethod.GetParameters().Length > 0)
                    {
                        if (oMethod.GetParameters()[0].ParameterType.ToString() == "System.Boolean")
                        {
                            if (Boolean.TryParse(sParamater, out bool bParamater) && oBooleans.Contains(sParamater.ToLower()))
                            {
                                sJSONResponse = JsonSerializer.Serialize(oMethod.Invoke(PluginHelper.StateManager.GetAllSelectedGames()[0], new object[] { bParamater }));
                                break;
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else
                        {
                            sJSONResponse = JsonSerializer.Serialize(oMethod.Invoke(PluginHelper.StateManager.GetAllSelectedGames()[0], new object[] { sParamater }));
                            break;
                        }
                    }
                }
            }

            WriteJSON(oHttpProcessor, sJSONResponse);
        }
        private void frmSettings_Load(object sender, EventArgs e)
        {
            txtPort.Text       = PluginAppSettings.GetInt("Port") == 0 ? "80" : PluginAppSettings.GetInt("Port").ToString();
            txtSecurePort.Text = PluginAppSettings.GetInt("SecurePort") == 0 ? "443" : PluginAppSettings.GetInt("SecurePort").ToString();

            chkPortEnabled.Checked            = PluginAppSettings.GetBoolean("PortEnabled");
            chkSecurePortEnabled.Checked      = PluginAppSettings.GetBoolean("SecurePortEnabled");
            nudSecondsBetweenRefresh.Value    = (PluginAppSettings.GetInt("SecondsBetweenRefresh") > 0 && PluginAppSettings.GetInt("SecondsBetweenRefresh") < 1000) ? PluginAppSettings.GetInt("SecondsBetweenRefresh") : 15;
            cmbAutomaticUpdates.SelectedIndex = cmbAutomaticUpdates.FindString(PluginAppSettings.GetBoolean("AutomaticUpdates") ? "On" : "Off");

            SetServerStatus();

            btnSave.Enabled            = false;
            btnCheckForUpdates.Enabled = true;
        }
Beispiel #4
0
        public void FirstTimeRunCheck()
        {
            if ((IsRunning.Item1 || port == -1) &&
                (IsRunning.Item2 || secure_port == -1) &&
                !PluginAppSettings.GetBoolean("NotFirstTimeRun"))
            {
                PluginAppSettings.SetString("NotFirstTimeRun", "True");
                PluginAppSettings.Save();

                if (IsRunning.Item1 || IsRunning.Item2)
                {
                    if (MessageBox.Show(Resources.FirstTimeRun, Resources.ApplicationName + " First Time Run",
                                        MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        LaunchIndexPage();
                    }
                }
            }
        }
Beispiel #5
0
        private static bool DoCacheResponseIfWarranted(HttpProcessor oHttpProcessor)
        {
            if (PluginAppSettings.GetBoolean("CacheDisabled"))
            {
                return(false);
            }

            // Cache the response in the browser using the Etag and If-None-Match
            if (oHttpProcessor.pathParts != null && oHttpProcessor.httpHeaders.ContainsKey("if-none-match") &&
                PluginHelper.StateManager.GetAllSelectedGames()?.Length == 1 &&
                oHttpProcessor.httpHeaders["if-none-match"] == oHttpProcessor.request_url + gsEtagSeperator +
                PluginHelper.StateManager.GetAllSelectedGames()[0].Id)
            {
                oHttpProcessor.writeNotModified();
                return(true);
            }

            return(false);
        }
Beispiel #6
0
        private void frmSettings_Load(object sender, EventArgs e)
        {
            txtPort.Text       = PluginAppSettings.GetInt("Port") == 0 ? "80" : PluginAppSettings.GetInt("Port").ToString();
            txtSecurePort.Text = PluginAppSettings.GetInt("SecurePort") == 0 ? "443" : PluginAppSettings.GetInt("SecurePort").ToString();

            chkPortEnabled.Checked            = PluginAppSettings.GetBoolean("PortEnabled");
            chkSecurePortEnabled.Checked      = PluginAppSettings.GetBoolean("SecurePortEnabled");
            nudSecondsBetweenRefresh.Value    = (PluginAppSettings.GetInt("SecondsBetweenRefresh") > 0 && PluginAppSettings.GetInt("SecondsBetweenRefresh") < 1000) ? PluginAppSettings.GetInt("SecondsBetweenRefresh") : 15;
            cmbAutomaticUpdates.SelectedIndex = cmbAutomaticUpdates.FindString(PluginAppSettings.GetBoolean("AutomaticUpdates") ? "On" : "Off");
            chkWriteEnabled.Checked           = PluginAppSettings.GetBoolean("WriteEnabled");

            SetServerStatus();

            btnSave.Enabled            = false;
            btnCheckForUpdates.Enabled = true;

            lblVersion.Text = PluginAppSettings.GetString("Version");

            // The version information in the config file overrides the assembly version.
            if (string.IsNullOrEmpty(lblVersion.Text))
            {
                lblVersion.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }
        }